| Visual Basic (Declaration) | |
|---|---|
<DescriptionAttribute("Connect to a server asynchronously. The EndConnect event is raised when completed.")> Public Overloads Overridable Function BeginConnect( _ ByVal server As String, _ ByVal serverPort As Integer, _ ByVal client As String, _ ByVal clientPortMin As Integer, _ ByVal clientPortMax As Integer, _ ByVal state As Object _ ) As IAsyncResult | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Tcp Dim server As String Dim serverPort As Integer Dim client As String Dim clientPortMin As Integer Dim clientPortMax As Integer Dim state As Object Dim value As IAsyncResult value = instance.BeginConnect(server, serverPort, client, clientPortMin, clientPortMax, state) | |
| C# | |
|---|---|
[DescriptionAttribute("Connect to a server asynchronously. The EndConnect event is raised when completed.")] public virtual IAsyncResult BeginConnect( string server, int serverPort, string client, int clientPortMin, int clientPortMax, object state ) | |
| Managed Extensions for C++ | |
|---|---|
[DescriptionAttribute("Connect to a server asynchronously. The EndConnect event is raised when completed.")] public: virtual IAsyncResult* BeginConnect( string* server, int serverPort, string* client, int clientPortMin, int clientPortMax, Object* state ) | |
| C++/CLI | |
|---|---|
[DescriptionAttribute("Connect to a server asynchronously. The EndConnect event is raised when completed.")] public: virtual IAsyncResult^ BeginConnect( String^ server, int serverPort, String^ client, int clientPortMin, int clientPortMax, Object^ state ) | |
Parameters
- server
- Remote hostname or address in dot notation.
- serverPort
- Remote port, a number between 1 and 65535, inclusive.
- client
- Optional local hostname or address in dot notation. Use "" as default.
- clientPortMin
- The minimum client port number to use as a local interface.
- clientPortMax
- The maximim client port number to use as a local interface.
- state
- User state information.
Return Value
An IAsyncResult that represents the asynchronous operation, which could still be pending.| Exception | Description |
|---|---|
| System.InvalidOperationException | BeginXXX method used without providing an EndXXX event handler. |
Use this method if you wish to connect to a host transparently with minimal application impact, as execution occurs on another thread. This method begins to asynchronously connect to the server. Upon completion (on both success and failure) the Tcp.EndConnect event is raised. An EventArgs object is passed into this event, containing information about the event. If the connection succeeds, the ConnectedChanged event is raised. Once the connection has been made, you can send and receive data from the remote device.
If you are using the Tcp component as a reference, you must "wire up" the event yourself. This involves creating a method as the event handler that implements the EventHandler delegate.
For more information on implementing and handling events using PowerTCP.NET, see the topic, Using Events In PowerTCP.
To connect synchronously, use the Tcp.Connect method.
Target Platforms: Microsoft .NET Framework 2.0