GEOS SDK TechDocs|
|
7 Sending and Receiving Data |
9 Checking the Connection SocketInterrupt(), SocketClose(), SocketCloseSend(), SocketReset(), SocketCloseDomainMedium()
To halt either an accept or receive operation in progress, call
SocketInterrupt()
. If no such operation is in progress but the socket is listening or connected, the next such operation will be interrupted. Look out for the error SE_SOCKET_NOT_INTERRUPTIBLE; this signals that a non-interruptible operation is taking place on the socket.
When it comes time to close the connection and/or free a socket, call
SocketClose()
or
SocketCloseSend()
.
SocketCloseSend()
works only with connected sockets. It partially shuts down the socket so that it can no longer send data; it can, however, still receive data. (Passing a partially closed socket to
SocketSend()
results in an SE_SOCKET_CLOSED error.)
SocketCloseSend()
sends an SE_CONNECTION_CLOSED exception packet to the other side of the connection to let it know that it's starting to shut itself down. Upon receipt of this exception packet, the other side of the connection will probably want to begin closing itself down as well.
Not all domains support closing the "send" part of a socket. In this case, the routine will return SE_CLOSE_SEND_NOT_SUPPORTED and you must use
SocketClose()
instead to close the connection and free the socket.
SocketClose()
closes the socket (shutting down both incoming and outgoing data) and frees it. This routine may be used on a socket in any state. You must use
SocketClose()
to close (and free) a datagram socket.
To close a connection with extreme prejudice, call
SocketReset()
. Use this routine with caution as it bypasses all normal protocol-level handshaking and unilaterally kills the connection. When using this routine, you should still call
SocketClose()
to free the socket data structures and flush any unread data.
The
SocketCloseDomainMedium()
routine can close all connections over a given medium without sending any notifications. It effectively hangs up the connection. You pass a flag to specify whether the routine should only hang up if there are no active connections through the medium, or hang regardless. For more information about socket media and this routine, see Hardware Ports.
GEOS SDK TechDocs|
|
7 Sending and Receiving Data |
9 Checking the Connection