Listen Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Places a Socket in a listening state.

Namespace:  System.Net.Sockets
Assembly:  System (in System.dll)

member Listen : 
        backlog:int -> unit 

Parameters

backlog
Type: System..::..Int32
The maximum length of the pending connections queue.

Listen causes a connection-oriented Socket to listen for incoming connection attempts. The backlog parameter specifies the number of incoming connections that can be queued for acceptance. To determine the maximum number of connections you can specify, retrieve the MaxConnections value. Listen does not block.

If you receive a SocketException, use the 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. Use Accept or BeginAccept to accept a connection from the queue.

NoteNote

You must call the Bind method before calling Listen, or Listen will throw a SocketException.

Show: