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

System.Net.Sockets.Socket.Listen Method

Places the current instance into the listening state where it waits for incoming connection requests. [Edit]

public void Listen (int backlog)

Parameters

backlog
A int containing the maximum length of the queue of pending connections. [Edit]

Exceptions

TypeReason
System.Net.Sockets.SocketExceptionThe Socket.Connected property of the current instance is true.

-or-

Bind has not been called on the current instance.

-or-

An error occurred while accessing the socket.

Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.

[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]

Remarks

Once this method is called, incoming connection requests are placed in a queue. The maximum size of the queue is specified by the backlog parameter. The size of the queue is limited to legal values by the underlying protocol. Illegal values of the backlog parameter are replaced with a legal value, which is implementation defined.

If a connection request arrives and the queue is full, a System.Net.Sockets.SocketException is thrown on the client.

A socket in the listening state has no remote endpoint associated with it. Attempting to access the Socket.RemoteEndPoint property throws a System.Net.Sockets.SocketException exception.

This method is ignored if called more than once on the current instance.

Note:

This method is used only on the server-side of connection-oriented protocols. Call the Socket.Bind(System.Net.EndPoint) method before this method is called the first time. Call the Socket.Listen(int) method before the first call to the Socket.Accept method.

[Edit]

Requirements

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