Ns_SockCloseLater
Overview
Close a remote connection which has not yet timed out.
Syntax
int Ns_SockCloseLater (
SOCKET sock
);
Description
Ns_SockCloseLater can be used to have the socket service thread close a socket which has yet to timeout after an Ns_SockAsyncConnect. (This is necessary on Windows NT where closesocket would block until final timeout.)
Example
SOCKET sock;
fd_set set;
struct timeval tv;
sock = Ns_SockAsyncConnect("mailhost", 25);
... perform some other work while connection is in progress...
... check for connection ...
tv.tv_sec = 2; /* allow 2 more seconds */
tv.tv_usec = 0;
FD_ZERO(&set);
FD_SET(sock, &set);
if (select(sock+1, NULL, &set, NULL, &tv) != 1) {
... timeout - close socket and return error...
Ns_CloseLater(sock);
} else {
... use socket ...
}