Listen Method  
 

Listen for incoming connections.

Syntax

object.Listen( [LocalAddress], [LocalPort], [Backlog] )

Parameters

LocalAddress
An optional string value that specifies the IP address the control should use when listening for connection requests. If this argument is not specified, the control will bind to any suitable IPv4 interface on the local system.
LocalPort
An optional integer value that specifies the local port number that be used to listen for connections. If this parameter is omitted, the LocalPort property will be used to determine the default port number. If this value is zero, the listening socket will be bound to a random port number.
Backlog
An optional integer value that specifies the maximum size of the queue used to manage pending connections to the service. If this parameter is set to value which exceeds the maximum size allowed by the operating system, it will be silently adjusted to the nearest legal value. If this parameter is omitted, the Backlog property will be used to determine the default value.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure. This method will return an error if a socket has already been created by a previous call to the Connect method.

Remarks

The Listen method causes the control to listen on a socket for incoming connections on a particular local address and local port. If an IPv6 address is specified as the local IP address, the system must have an IPv6 stack installed and configured, otherwise the method will fail.

To listen for connections on any suitable IPv4 interface, specify the special dotted-quad address "0.0.0.0". You can accept connections from clients using either IPv4 or IPv6 on the same socket by specifying the special IPv6 address "::0", however this is only supported on Windows 7 and Windows Server 2008 R2 or later platforms. If no local address is specified, then the server will only listen for connections from clients using IPv4. This behavior is by design for backwards compatibility with systems that do not have an IPv6 TCP/IP stack installed.

See Also

Backlog Property, LocalPort Property, Accept Method, Connect Method, Reject Method, OnAccept Event