summaryrefslogtreecommitdiffstats
path: root/otherlibs
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs')
-rw-r--r--otherlibs/unix/unix.ml4
-rw-r--r--otherlibs/unix/unix.mli19
2 files changed, 22 insertions, 1 deletions
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index 060b904bb..59f3bc730 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -385,6 +385,8 @@ type socket_option =
external socket : socket_domain -> socket_type -> int -> file_descr
= "unix_socket"
+external async_socket : socket_domain -> socket_type -> int -> file_descr
+ = "unix_socket"
external socketpair :
socket_domain -> socket_type -> int -> file_descr * file_descr
= "unix_socketpair"
@@ -651,6 +653,6 @@ let establish_server server_fun sockaddr =
server_fun inchan outchan;
close_in inchan;
close_out outchan
- | id -> close s; let _ = waitpid [] id (* Reclaim the son *) in ()
+ | id -> close s; ignore(waitpid [] id) (* Reclaim the son *)
done
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index 5fac6cd99..de7ed74d4 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -705,6 +705,25 @@ val socket : socket_domain -> socket_type -> int -> file_descr
(* Create a new socket in the given domain, and with the
given kind. The third argument is the protocol type; 0 selects
the default protocol for that kind of sockets. *)
+val async_socket : socket_domain -> socket_type -> int -> file_descr
+ (* Same as [socket], but creates an asynchronous socket.
+ Under Unix, there is no distinction between
+ asynchronous/synchronous sockets, so [async_socket] is
+ synonymous for [socket].
+ Under Windows, there are two kinds of sockets.
+ Synchronous sockets behave like regular file descriptors:
+ you can use [read] and [write] to do I/O on them,
+ as well as pass them as standard input/output to another
+ process. However, synchronous sockets do not support
+ event-based notification in GUIs such as CamlTk, and in
+ particular cannot be passed as argument to
+ [Fileevent.add_fileinput] and [Fileevent.add_fileoutput] in CamlTk.
+ Asynchronous sockets can be used with [Fileevent.add_fileinput]
+ and [Fileevent.add_fileoutput], but must be read with [recv]
+ and written with [send]. They cannot be used with [read],
+ [write], nor as standard input/output of another process.
+ As a rule of thumb, use [async_socket] to create sockets
+ that need to be passed to CamlTk, and [socket] otherwise. *)
val socketpair :
socket_domain -> socket_type -> int -> file_descr * file_descr
(* Create a pair of unnamed sockets, connected together. *)