37 extern HANDLE fd_to_handle(
int fd) {
    39     HANDLE handle = (HANDLE)_get_osfhandle(fd);
    40     if (handle != INVALID_HANDLE_VALUE) 
return handle;
    48     return reinterpret_cast<HANDLE
>(intptr_t(fd));
    54     if (
close(fd) == -1 && errno == EBADF) {
    68 #if defined SO_SNDTIMEO || defined SO_RCVTIMEO    76         if (
usual(timeout < numeric_limits<DWORD>::max() / 1000))
    79             t = numeric_limits<DWORD>::max();
    82         (void)setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO,
    83                          reinterpret_cast<char*>(&t), 
sizeof(t));
    86         (void)setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,
    87                          reinterpret_cast<char*>(&t), 
sizeof(t));
   101         (void)setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
   102                          reinterpret_cast<char*>(&flag), 
sizeof(flag));
 
void set_socket_timeouts(int fd, double timeout)
Attempt to set socket-level timeouts. 
 
unsigned timeout
A timeout value in milliseconds. 
 
Work around MSVC's unhelpful non-standard invalid parameter handling. 
 
include <sys/socket.h> with portability workarounds. 
 
void close_fd_or_socket(int fd)
 
Socket handling utilities. 
 
void to_timeval(double t, struct timeval *tv)
Fill in struct timeval from number of seconds in a double. 
 
Functions for handling a time or time interval in a double.