2003-01-06 08:44:21 -08:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2011-07-27 07:17:02 -07:00
|
|
|
/* OCaml */
|
2003-01-06 08:44:21 -08:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 2002 Institut National de Recherche en Informatique et */
|
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
2014-12-27 06:41:49 -08:00
|
|
|
#include <caml/mlvalues.h>
|
|
|
|
#include <caml/signals.h>
|
2003-01-06 08:44:21 -08:00
|
|
|
#include "unixsupport.h"
|
|
|
|
|
|
|
|
CAMLprim value unix_set_nonblock(socket)
|
|
|
|
value socket;
|
|
|
|
{
|
|
|
|
u_long non_block = 1;
|
|
|
|
|
|
|
|
if (ioctlsocket(Socket_val(socket), FIONBIO, &non_block) != 0) {
|
|
|
|
win32_maperr(WSAGetLastError());
|
|
|
|
uerror("unix_set_nonblock", Nothing);
|
|
|
|
}
|
2011-10-15 02:02:22 -07:00
|
|
|
Flags_fd_val(socket) = Flags_fd_val(socket) & ~FLAGS_FD_IS_BLOCKING;
|
2003-01-06 08:44:21 -08:00
|
|
|
return Val_unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
CAMLprim value unix_clear_nonblock(socket)
|
|
|
|
value socket;
|
|
|
|
{
|
|
|
|
u_long non_block = 0;
|
|
|
|
|
|
|
|
if (ioctlsocket(Socket_val(socket), FIONBIO, &non_block) != 0) {
|
|
|
|
win32_maperr(WSAGetLastError());
|
|
|
|
uerror("unix_clear_nonblock", Nothing);
|
|
|
|
}
|
2011-10-15 02:02:22 -07:00
|
|
|
Flags_fd_val(socket) = Flags_fd_val(socket) | FLAGS_FD_IS_BLOCKING;
|
2003-01-06 08:44:21 -08:00
|
|
|
return Val_unit;
|
|
|
|
}
|