blob: f88de5307e17cb02dc5dd8cec351a289d9b6c37e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/**************************************************************************/
/* */
/* OCaml */
/* */
/* 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 Lesser General Public License version 2.1, with the */
/* special exception on linking described in the file LICENSE. */
/* */
/**************************************************************************/
#include <caml/mlvalues.h>
#include <caml/signals.h>
#include "unixsupport.h"
CAMLprim value caml_unix_set_nonblock(value socket)
{
u_long non_block = 1;
if (ioctlsocket(Socket_val(socket), FIONBIO, &non_block) != 0) {
caml_win32_maperr(WSAGetLastError());
caml_uerror("caml_unix_set_nonblock", Nothing);
}
Flags_fd_val(socket) = Flags_fd_val(socket) & ~FLAGS_FD_IS_BLOCKING;
return Val_unit;
}
CAMLprim value caml_unix_clear_nonblock(value socket)
{
u_long non_block = 0;
if (ioctlsocket(Socket_val(socket), FIONBIO, &non_block) != 0) {
caml_win32_maperr(WSAGetLastError());
caml_uerror("caml_unix_clear_nonblock", Nothing);
}
Flags_fd_val(socket) = Flags_fd_val(socket) | FLAGS_FD_IS_BLOCKING;
return Val_unit;
}
|