Mono Class Library: System.Net.Sockets.Socket Overview | Members

System.Net.Sockets.Socket.Connect Method

Associates the current instance with a remote endpoint. [Edit]

public void Connect (System.Net.EndPoint remote_end)

Parameters

remote_end
The System.Net.EndPoint associated with the socket to connect to. [Edit]

Permissions

TypeReason
System.Net.SocketPermission [Edit] Requires permission to make a connection to the endpoint defined by remoteEP. See System.Net.NetworkAccess.Connect.

Exceptions

TypeReason
ArgumentNullExceptionremoteEP is null. [Edit]
InvalidOperationExceptionAn asynchronous call is pending and a blocking method has been called. [Edit]
System.Net.Sockets.SocketException
Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.
[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]
System.Security.SecurityException A caller in the call stack does not have the required permission. [Edit]

Remarks

This method sets the Socket.RemoteEndPoint property of the current instance to remoteEP.

Note:

For connection-oriented protocols, this method establishes a connection between the current instance and the socket associated with remoteEP. This method is used only on the client-side. The Socket.Accept method establishes the connection on the server-side. Once the connection has been made, data can be sent using the Socket.Send(Byte[], int, SocketFlags) method, and received using the Socket.Receive(Byte[], int, SocketFlags) method.

For connectionless protocols, the Socket.Connect(System.Net.EndPoint) method can be used from both client and server-sides, allowing the use of the Socket.Send(Byte[], int, SocketFlags) method instead of the Socket.SendTo(Byte[], int, int, SocketFlags, System.Net.EndPoint) method. The Socket.RemoteEndPoint property is set to remoteEP and the Socket.LocalEndPoint property is set to a value determined by the protocol; however, a connection is not established. Subsequent data is required to be received on the endpoint set in the Socket.LocalEndPoint property.

[Edit]

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0