INT WINAPI InetDisconnect( |
|
SOCKET hSocket |
|
); |
The InetDisconnect function terminates the connection,
closing the socket and releasing the memory allocated for the
session.
Parameters
- hSocket
- The socket handle.
Return Value
If the function succeeds, the return value is zero. If the
function fails, the return value is INET_ERROR. To get extended error
information, call InetGetLastError.
Remarks
Once the connection has been terminated, the socket handle is no
longer valid 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 connection is established. An application should always consider
the socket handle to be opaque and never depend on it being a
specific value.
After a socket is closed, it will go into a TIME-WAIT state which
prevents an application from using the same source and destination
address and port numbers 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. This can have an impact on an application that
rapidly connects and disconnects over a short period of time because
it can exhaust the pool of ephemeral ports.
If this function is called using a server socket handle returned by the
InetServerStart function, all active client connections will
be disconnected, the listening socket will be closed and the server
thread will terminate. If this function is called using a client
socket handle that was allocated as part of the SocketWrench server
interface, it will terminate the client connection and the thread
that manages it.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header: Include cswsock10.h
Import Library: cswskv10.lib
See Also
InetAsyncConnect,
InetAsyncConnectEx,
InetConnect,
InetConnectEx,
InetDisableEvents,
InetEnableEvents,
InetUninitialize
|