X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fio-layer%2Fsockets.c;h=b2cf55faf211c4398f153bba7e86636c7d907b4a;hb=a6bce082e4da5a3f144b7ae8974819a88efb6817;hp=d22dde23c0c1ca75994fa3d69ec20cd7d90a1c21;hpb=922789d7b672f285c3285c3632ca6a504a337415;p=mono.git diff --git a/mono/io-layer/sockets.c b/mono/io-layer/sockets.c index d22dde23c0c..b2cf55faf21 100644 --- a/mono/io-layer/sockets.c +++ b/mono/io-layer/sockets.c @@ -122,8 +122,6 @@ cleanup_close (gpointer handle, gpointer data) int WSACleanup(void) { - guint32 i; - #ifdef DEBUG g_message ("%s: cleaning up", __func__); #endif @@ -394,7 +392,9 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval, { gpointer handle = GUINT_TO_POINTER (fd); int ret; - + struct timeval tv; + void *tmp_val; + if (startup_count == 0) { WSASetLastError (WSANOTINITIALISED); return(SOCKET_ERROR); @@ -404,8 +404,14 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval, WSASetLastError (WSAENOTSOCK); return(SOCKET_ERROR); } - - ret = getsockopt (fd, level, optname, optval, optlen); + + tmp_val = optval; + if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) { + tmp_val = &tv; + *optlen = sizeof (tv); + } + + ret = getsockopt (fd, level, optname, tmp_val, optlen); if (ret == -1) { gint errnum = errno; #ifdef DEBUG @@ -418,6 +424,11 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval, return(SOCKET_ERROR); } + + if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) { + *((int *) optval) = tv.tv_sec * 1000 + tv.tv_usec; + *optlen = sizeof (int); + } return(ret); } @@ -603,6 +614,8 @@ int _wapi_setsockopt(guint32 fd, int level, int optname, { gpointer handle = GUINT_TO_POINTER (fd); int ret; + const void *tmp_val; + struct timeval tv; if (startup_count == 0) { WSASetLastError (WSANOTINITIALISED); @@ -613,8 +626,17 @@ int _wapi_setsockopt(guint32 fd, int level, int optname, WSASetLastError (WSAENOTSOCK); return(SOCKET_ERROR); } - - ret = setsockopt (fd, level, optname, optval, optlen); + + tmp_val = optval; + if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) { + int ms = *((int *) optval); + tv.tv_sec = ms / 1000; + tv.tv_usec = ms % 1000; + tmp_val = &tv; + optlen = sizeof (tv); + } + + ret = setsockopt (fd, level, optname, tmp_val, optlen); if (ret == -1) { gint errnum = errno; #ifdef DEBUG