summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/accept.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1999-02-24 16:01:16 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1999-02-24 16:01:16 +0000
commit0b11fd35473a123c38e0f22b1efc852f79c26791 (patch)
tree0b4db392a97fbabc724c7425dab735ae7e0cd113 /otherlibs/win32unix/accept.c
parent5038f3cdb6377dfc84e4642b710c1a1949060e1d (diff)
Sockets asynchrones, suite
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2305 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/accept.c')
-rw-r--r--otherlibs/win32unix/accept.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/otherlibs/win32unix/accept.c b/otherlibs/win32unix/accept.c
index b55693ffa..90a0860df 100644
--- a/otherlibs/win32unix/accept.c
+++ b/otherlibs/win32unix/accept.c
@@ -17,19 +17,20 @@
#include "unixsupport.h"
#include "socketaddr.h"
-value unix_accept(sock) /* ML */
- value sock;
+value unix_accept(sock, synchronous) /* ML */
+ value sock, synchronous;
{
SOCKET sconn = (SOCKET) Handle_val(sock);
SOCKET snew;
value fd = Val_unit, adr = Val_unit, res;
- int oldvalue, newvalue, retcode;
+ int oldvalue, oldvaluelen, newvalue, retcode;
+ oldvaluelen = sizeof(oldvalue);
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
- (char *) &oldvalue, sizeof(oldvalue));
+ (char *) &oldvalue, &oldvaluelen);
if (retcode == 0) {
- /* Set sockets to synchronous mode */
- newvalue = SO_SYNCHRONOUS_NONALERT;
+ /* Set sockets to synchronous or asnychronous mode, as requested */
+ newvalue = Bool_val(synchronous) ? SO_SYNCHRONOUS_NONALERT : 0;
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
(char *) &newvalue, sizeof(newvalue));
}
@@ -40,7 +41,7 @@ value unix_accept(sock) /* ML */
if (retcode == 0) {
/* Restore initial mode */
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
- (char *) &oldvalue, sizeof(oldvalue));
+ (char *) &oldvalue, oldvaluelen);
}
if (snew == INVALID_SOCKET)
unix_error(WSAGetLastError(), "accept", Nothing);