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.
exception Error of
val create_socket :
int -> int -> socket
create_socket port client_limitshould be called on the server to create a socket waiting for new clients. The clients should then connect to the given
client_limitis 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
val check_socket :
socket -> socket list
check_socket socketshould 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 -> socket
connect hostname portWhen called on a client it tries to connect to the given server and
portand returns connected socket or throws Not_available
val write :
socket -> string -> int -> int -> string
write socket str pos lenJust like Unix.write
val read :
socket -> string list
read socketmay return an empty list
val force_read :
socket -> string
val close :
socket -> unit
close socketwhen 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).