Creates a new System.Net.Sockets.Socket for a newly created connection.
A System.Net.Sockets.Socket for a newly created connection.
Type Reason ArgumentException An error occurred while creating the new System.Net.Sockets.Socket. InvalidOperationException An asynchronous call is pending and a blocking method has been called. 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.ObjectDisposedException The current instance has been disposed.
Socket.Accept synchronously extracts the first pending connection request from the connection request queue of the listening socket, and then creates and returns a new System.Net.Sockets.Socket. You cannot use this returned System.Net.Sockets.Socket to accept any additional connections from the connection queue. However, you can call the Socket.RemoteEndPoint method of the returned System.Net.Sockets.Socket to identify the remote host's network address and port number.
In blocking mode, Socket.Accept blocks until an incoming connection attempt is queued. Once a connection is accepted, the original System.Net.Sockets.Socket continues queuing incoming connection requests until you close it.
If you call this method using a non-blocking System.Net.Sockets.Socket, and no connection requests are queued, Socket.Accept throws a System.Net.Sockets.SocketException. If you receive a System.Net.Sockets.SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.
Before calling the Socket.Accept method, you must first call the Socket.Listen(int) method to listen for and queue incoming connection requests.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].