From 96e3e928a257a9eec9fba251912142818425ff13 Mon Sep 17 00:00:00 2001 From: Greg Turner <gmturner007@ameritech.net> Date: Wed, 25 Sep 2002 00:15:43 +0000 Subject: [PATCH] Accept time_t argument in WS_setsockopt/WS_SO_RCVTIMEO; translate to struct timeval for edification of setsockopt. --- dlls/winsock/socket.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c index 12f38a99166..2ab18409196 100644 --- a/dlls/winsock/socket.c +++ b/dlls/winsock/socket.c @@ -2670,6 +2670,7 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, { struct linger linger; int woptval; + struct timeval tval; /* Is a privileged and useless operation, so we don't. */ if ((optname == WS_SO_DEBUG) && (level == WS_SOL_SOCKET)) { @@ -2704,6 +2705,21 @@ int WINAPI WS_setsockopt(SOCKET s, int level, int optname, optval= (char*) &woptval; optlen=sizeof(int); } + if (level == SOL_SOCKET && optname == SO_RCVTIMEO && optlen < sizeof(struct timeval)) { + if (optlen == sizeof(time_t)) { + /* Apparently WinSock will accept a shortened struct timeval. + FIXME: should we do the same for SO_SNDTIMEO? */ + WARN("Short struct timeval in SO_RCVTIMEO: assuming time_t\n"); + tval.tv_sec = *(time_t*)optval; + tval.tv_usec = 0; + optlen = sizeof(struct timeval); + optval = (char*)&tval; + } else { + WARN("SO_RCVTIMEO for %d bytes is too small: ignored\n", optlen); + close(fd); + return 0; + } + } } if(optname == SO_RCVBUF && *(int*)optval < 2048) { WARN("SO_RCVBF for %d bytes is too small: ignored\n", *(int*)optval ); -- GitLab