| BOOL InetServerStop(
|
|
|
SOCKET hServer |
|
| );
|
The InetServerStop function disconnects all active client
connections, closes the listening socket and terminates the server
thread.
Parameters
- hServer
- Handle to the server socket.
Return Value
If the function succeeds, the return value is non-zero. If the
function fails, the return value is zero. To get extended error
information, call InetGetLastError.
Remarks
The InetServerStop function instructs the
server to stop accepting client connections, disconnects all active
client connections and terminate the thread that is managing the
server session. The socket handle is no longer valid after the
server has been stopped and should no longer be used. Note that it
is possible that the actual handle value may be re-used at a later
point when a new server is started. An application should always
consider the socket handle to be opaque and never depend on it
being a specific value.
If this function is called when there is one or more clients
connected to the server, the server thread will signal each client
and wait for the client thread to terminate. As a result, it is
possible for INET_EVENT_DISCONNECT events to be generated for those
client sessions after the InetServerStop function
has been called. If you want your application to wait until the
server thread has terminated, you can use the
InetGetServerThreadId function to obtain the
server's thread ID, call the OpenThread function
for a handle to the thread, and then call
WaitForSingleObject using that handle.
After the server thread has been terminated, the listening
socket will go into a TIME-WAIT state which prevents an application
from reusing the same address and port number bound to that socket
for a brief period of time, typically two to four minutes. This is
normal behavior designed to prevent delayed or misrouted packets of
data from being read by a subsequent connection. To immediately
start a new server using the same local address and port number,
the option INET_OPTION_REUSEADDR must be specified when calling the
InetServerStart function.
The socket handle for the server must be one that was created by
calling the InetServerStart function, and cannot
be a socket that was created using the InetListen
or InetListenEx functions.
Requirements
Client: Requires Windows Vista, Windows XP or Windows
2000 Professional.
Server: Requires Windows Server 2008, Windows Server 2003 or
Windows 2000 Server.
Header: Include cswsock6.h.
Library: Use cswskav6.lib.
See Also
InetGetServerStatus,
InetServerRestart, InetServerResume, InetServerStart, InetServerSuspend
|