diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2012-07-26 19:21:54 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2012-07-26 19:21:54 +0000 |
commit | 0c3a7de5079529bc99cbc9e68806f1a7021d94ef (patch) | |
tree | 3b973b6db6313c9bb2993b77c925c0dc8b457f7a /otherlibs/win32unix/socket.c | |
parent | 229044d83a940d855fd9590d9aa76596f8c1a8b9 (diff) |
merge changes from 4.00 branching to 4.00.0 (part 1)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12784 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/socket.c')
-rw-r--r-- | otherlibs/win32unix/socket.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/otherlibs/win32unix/socket.c b/otherlibs/win32unix/socket.c index 4aabe5e45..908ffb729 100644 --- a/otherlibs/win32unix/socket.c +++ b/otherlibs/win32unix/socket.c @@ -33,6 +33,7 @@ CAMLprim value unix_socket(domain, type, proto) value domain, type, proto; { SOCKET s; + int oldvalue, oldvaluelen, newvalue, retcode; #ifndef HAS_IPV6 /* IPv6 requires WinSock2, we must raise an error on PF_INET6 */ @@ -42,9 +43,23 @@ CAMLprim value unix_socket(domain, type, proto) } #endif + oldvaluelen = sizeof(oldvalue); + retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + (char *) &oldvalue, &oldvaluelen); + if (retcode == 0) { + /* Set sockets to synchronous mode */ + newvalue = SO_SYNCHRONOUS_NONALERT; + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + (char *) &newvalue, sizeof(newvalue)); + } s = socket(socket_domain_table[Int_val(domain)], socket_type_table[Int_val(type)], Int_val(proto)); + if (retcode == 0) { + /* Restore initial mode */ + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + (char *) &oldvalue, oldvaluelen); + } if (s == INVALID_SOCKET) { win32_maperr(WSAGetLastError()); uerror("socket", Nothing); |