NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Socket.Connect

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;

Parameters

remoteEP
An EndPoint instance representing the remote system.

Return Value

0 if the connection was successful; otherwise, a non-zero error code.

Remarks

Bind must be called before Connect.

Requirements

NGWS Runtime Security:

NetworkAccess.Connect Must have connect permission to remoteEP.

Example [C#]

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()) );

}

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace