summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>1999-02-24 16:35:33 +0000
committerXavier Leroy <xavier.leroy@inria.fr>1999-02-24 16:35:33 +0000
commitbe894f1d3a01f3679dfd98d48e93aedeb76d7d48 (patch)
treeb6faf6d1f113faa76e8135ed2f990accd98a5ea3
parent138526c31b34e1007a4ebba88f31996aba6f1ed9 (diff)
Retour en arriere sur les sockets asynchrones (ne marche pas avec tk)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2307 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--otherlibs/unix/unix.ml5
-rw-r--r--otherlibs/unix/unix.mli25
-rw-r--r--otherlibs/win32unix/accept.c8
-rw-r--r--otherlibs/win32unix/socket.c6
-rw-r--r--otherlibs/win32unix/unix.ml14
5 files changed, 10 insertions, 48 deletions
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index f2bdc7b91..5d5fca081 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -385,15 +385,10 @@ 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"
external accept : file_descr -> file_descr * sockaddr = "unix_accept"
-
-external async_accept : file_descr -> file_descr * sockaddr = "unix_accept"
-
external bind : file_descr -> sockaddr -> unit = "unix_bind"
external connect : file_descr -> sockaddr -> unit = "unix_connect"
external listen : file_descr -> int -> unit = "unix_listen"
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index 46d40c30d..5fac6cd99 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -705,25 +705,6 @@ 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. *)
@@ -731,12 +712,6 @@ val accept : file_descr -> file_descr * sockaddr
(* Accept connections on the given socket. The returned descriptor
is a socket connected to the client; the returned address is
the address of the connecting client. *)
-val async_accept : file_descr -> file_descr * sockaddr
- (* Same as [accept], but the returned socket is set to
- asynchronous mode. See [async_socket] for a discussion of
- synchronous vs. asynchronous mode.
- As a rule of thumb, use [async_accept] if you're going to pass
- the socket to CamlTk, and [accept] otherwise. *)
val bind : file_descr -> sockaddr -> unit
(* Bind a socket to an address. *)
val connect : file_descr -> sockaddr -> unit
diff --git a/otherlibs/win32unix/accept.c b/otherlibs/win32unix/accept.c
index 90a0860df..1c45ade0c 100644
--- a/otherlibs/win32unix/accept.c
+++ b/otherlibs/win32unix/accept.c
@@ -17,8 +17,8 @@
#include "unixsupport.h"
#include "socketaddr.h"
-value unix_accept(sock, synchronous) /* ML */
- value sock, synchronous;
+value unix_accept(sock) /* ML */
+ value sock;
{
SOCKET sconn = (SOCKET) Handle_val(sock);
SOCKET snew;
@@ -29,8 +29,8 @@ value unix_accept(sock, synchronous) /* ML */
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
(char *) &oldvalue, &oldvaluelen);
if (retcode == 0) {
- /* Set sockets to synchronous or asnychronous mode, as requested */
- newvalue = Bool_val(synchronous) ? SO_SYNCHRONOUS_NONALERT : 0;
+ /* Set sockets to synchronous mode */
+ newvalue = SO_SYNCHRONOUS_NONALERT;
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
(char *) &newvalue, sizeof(newvalue));
}
diff --git a/otherlibs/win32unix/socket.c b/otherlibs/win32unix/socket.c
index 5e8d218ec..a69867cfd 100644
--- a/otherlibs/win32unix/socket.c
+++ b/otherlibs/win32unix/socket.c
@@ -24,7 +24,7 @@ int socket_type_table[] = {
SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET
};
-value unix_socket(domain, type, proto, synchronous) /* ML */
+value unix_socket(domain, type, proto) /* ML */
value domain, type, proto;
{
SOCKET s;
@@ -34,8 +34,8 @@ value unix_socket(domain, type, proto, synchronous) /* ML */
retcode = getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
(char *) &oldvalue, &oldvaluelen);
if (retcode == 0) {
- /* Set sockets to synchronous or asnychronous mode, as requested */
- newvalue = Bool_val(synchronous) ? SO_SYNCHRONOUS_NONALERT : 0;
+ /* Set sockets to synchronous mode */
+ newvalue = SO_SYNCHRONOUS_NONALERT;
setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
(char *) &newvalue, sizeof(newvalue));
}
diff --git a/otherlibs/win32unix/unix.ml b/otherlibs/win32unix/unix.ml
index eb16b8a8c..17eecb0d8 100644
--- a/otherlibs/win32unix/unix.ml
+++ b/otherlibs/win32unix/unix.ml
@@ -476,18 +476,10 @@ type socket_option =
| SO_DONTROUTE
| SO_OOBINLINE
-external socket_internal :
- socket_domain -> socket_type -> int -> bool -> file_descr
- = "unix_socket"
-
-let socket dom typ proto = socket_internal dom typ proto true
-let async_socket dom typ proto = socket_internal dom typ proto false
+external socket : socket_domain -> socket_type -> int -> file_descr
+ = "unix_socket"
let socketpair dom ty proto = invalid_arg "Unix.socketpair not implemented"
-
-external accept_internal :
- file_descr -> bool -> file_descr * sockaddr = "unix_accept"
-let accept s = accept_internal s true
-let async_accept s = accept_internal s false
+external accept : file_descr -> file_descr * sockaddr = "unix_accept"
external bind : file_descr -> sockaddr -> unit = "unix_bind"
external connect : file_descr -> sockaddr -> unit = "unix_connect"
external listen : file_descr -> int -> unit = "unix_listen"