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

System.Net.Sockets.Socket.Bind Method

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

public void Bind (System.Net.EndPoint local_end)

Parameters

local_end
The local System.Net.EndPoint to be associated with the socket. [Edit]

Permissions

TypeReason
System.Net.SocketPermission [Edit] Requires permission to accept connections on the endpoint defined by localEP. See System.Net.NetworkAccess.Accept.

Exceptions

TypeReason
ArgumentNullExceptionlocalEP is null. [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.LocalEndPoint property of the current instance to localEP.

Note:

For connection-oriented protocols, this method is generally used only on the server-side and is required to be called before the first call to the Socket.Listen(int) method. On the client-side, binding is usually performed implicitly by the Socket.Connect(System.Net.EndPoint) method.

For connectionless protocols, the Socket.Connect(System.Net.EndPoint)Socket.SendTo(Byte[], int, int, SocketFlags, System.Net.EndPoint), and Socket.BeginSendTo(Byte[], int, int, SocketFlags, System.Net.EndPoint, AsyncCallback, object) methods bind the current instance to the local endpoint if the current instance has not previously been bound.

[Edit]

Requirements

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