NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Socket.Accept

Creates a new Socket instance to handle an incoming connection.

[Visual Basic]
Public Function Accept() As Socket
[C#]
public Socket Accept();
[C++]
public: Socket* Accept();
[JScript]
public function Accept() : Socket;

Return Value

If there is a pending connection request, a Socket instance to handle the incoming connection. If there is no pending connection for an asynchronous socket, a null reference (in Visual Basic Nothing).

Exceptions

Exception Type Condition
InvalidOperationException The Accept call is made on a synchronous socket with no pending connection requests.

Remarks

The Accept method extracts the first connection request on the queue of pending requests and creates a new Socket instance to handle the request. The Socket returned by Accept is a duplicate of the current Socket.If Accept is called on an asynchronous socket with no pending connection requests, null will be returned.

Example [C#]

The following code will display any error message returned by Accept.

[C#]

result = aSocket.Accept
if (result <> 0)
{
   Console.WriteLine("Winsock error: " + Convert.ToString(Marshal.GetLastWin32Error()) );

}

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace