The InetAsyncListenEx function creates a listening socket
and specifies the maximum number of connection requests that will be queued.
This function has been deprecated and may be unavailable in future
releases. It was designed for use in legacy single-threaded applications
and requires the application to have a message pump to process event
messages. It should not be used with applications which are designed
to execute as a service or those which do not have a graphical user
interface.
New projects should use the InetServerStart
function to to create a server application.
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.
If the INET_OPTION_REUSEADDRESS option is not specified, an error may
be returned if a listening socket was recently created for the same
local address and port number. By default, once a listening socket is
closed there is a period of time that all applications must wait
before the address can be reused (this is called the TIME_WAIT
state). The actual amount of time depends on the operating system and
configuration parameters, but is typically two to four minutes.
Specifying this option enables an application to immediately re-use a
local address and port number that was previously in use.
If the INET_OPTION_EXCLUSIVE option is specified, the local address
and port number cannot be used by another process until the listening
socket is closed. This can prevent another application from forcibly
binding to the same listening address as your server. This option can
be useful in determining whether or not another process is already
bound to the address you wish to use, but it may also prevent your
server application from restarting immediately, regardless if the
INET_OPTION_REUSEADDRESS option has also been specified.
If an IPv6 address is specified as the local address, the system
must have an IPv6 stack installed and configured, otherwise the
function will fail.
When a message is posted to the notification window, the low word
of the lParam parameter contains the event identifier. The
high word of lParam contains the low word of the error code,
if an error has occurred. The wParam parameter contains the
socket handle. One or more of the following event identifiers may be
sent: