module Tcp: sig end
Tcp.socket's should not be compared, since on some systems
(eg. Windows) such a comparison may fail. If comparison is
required see Socket.t.
On a client there should be a single socket for every server. On a
server for every one waiting for new connections (Created by
Tcp.create_socket) there are some connected to every client.
Every TCP socket is full duplex.
type socket
exception Lost
exception Error of string
val create_socket : int -> int -> socketcreate_socket port client_limit should be called on the server
to create a socket waiting for new clients. The clients should
then connect to the given port. client_limit is the limit
for clients that are trying to connect at the same time. This is
not the limit of connected clients, but the limit for clients trying
to connect until Tcp.check_socket is called.val check_socket : socket -> socket listcheck_socket socket should be called only on the server on a socket
created by Tcp.create_socket. It returns a list of new sockets, one for
every new connected client.val connect : string -> int -> socketconnect hostname port When called on a client it tries to connect to
the given server and port and returns connected socket or throws
Not_availableval write : socket -> string -> int -> int -> stringwrite socket str pos len Just like Unix.writeval read : socket -> string listread socket may return an empty listval force_read : socket -> stringforce_read socket blockingval close : socket -> unitclose socket when called on the client disconnects from the server,
when called on the server on a created socket it stops accepting client
and when called on the server with a socket from a client it closes the
connection to the client (to the client it looks like the connection
has been lost).