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)

Syntax

'Declaration
Public Sub Listen ( _
    backlog As Integer _
)
public void Listen(
    int backlog
)
public:
void Listen(
    int backlog
)
member Listen : 
        backlog:int -> unit 
public function Listen(
    backlog : int
)

Parameters

Remarks

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.

Note

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

.NET Framework Security

See Also

Reference

Socket Class

System.Net.Sockets Namespace