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

System.Net.Sockets.Socket.Accept Method

Creates and initializes a new System.Net.Sockets.Socket instance and connects it to an incoming connection request. [Edit]

public Socket Accept ()

Returns

A new connected System.Net.Sockets.Socket instance. [Edit]

Exceptions

TypeReason
ArgumentExceptionAn error occurred while creating the new System.Net.Sockets.Socket. [Edit]
InvalidOperationExceptionAn asynchronous call is pending and a blocking method has been called. [Edit]
System.Net.Sockets.SocketException

An error occurred while accessing the listening socket or while creating the new socket.

-or-

The Socket.Blocking property is set to false.

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

This method is used only on the server-side of connection-oriented protocols. It extracts the first connection request from the queue of pending requests, creates a new System.Net.Sockets.Socket instance, and connects this instance to the socket associated with the request.

The Socket.Blocking property of the socket determines the behavior of this method when there are no pending connection requests. When false, this method will throw a System.Net.Sockets.SocketException. When true, this method blocks.

The following properties of the new System.Net.Sockets.Socket instance returned by this method have values identical to the corresponding properties of the current instance:

The Socket.RemoteEndPoint property of the new instance is set to the local endpoint of the first request in the input queue. The Socket.Connected property is set to true.

[Edit]

Requirements

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