Establishes a connection to a remote system.
[Visual Basic] Public Function Connect( _ ByVal remoteEP As EndPoint _ ) As Integer [C#] public int Connect( EndPoint remoteEP ); [C++] public: int Connect( EndPoint* remoteEP ); [JScript] public function Connect( remoteEP : EndPoint ) : int;
0 if the connection was successful; otherwise, a non-zero error code.
Bind must be called before Connect.
NGWS Runtime Security:
NetworkAccess.Connect | Must have connect permission to remoteEP. |
If the socket cannot be connected to the end point, Connect will return a non-zero value indicating the error. The following code attempts to connect a socket to an end point. If the connect attempt is unsuccessful, the error code is written to the console.
[C#]
result = aSocket.Connect(anEndPoint); if (result <> 0) { Console.WriteLine("Winsock error: " + Convert.ToString(Marshal.GetLastWin32Error()) ); }
Socket Class | Socket Members | System.Net.Sockets Namespace