signature MLTON_SOCKET = sig structure Address: sig type t = word end structure Ctl: sig val getERROR: ('a, 'b) Socket.sock -> (string * int option) option end structure Host: sig type t = {name: string} val getByAddress: Address.t -> t option val getByName: string -> t option end structure Port: sig type t = int end type t val accept: t -> Address.t * Port.t * TextIO.instream * TextIO.outstream val connect: string * Port.t -> TextIO.instream * TextIO.outstream val fdToSock: Posix.FileSys.file_desc -> ('a, 'b) Socket.sock val listen: unit -> Port.t * t val listenAt: Port.t -> t val shutdownRead: TextIO.instream -> unit val shutdownWrite: TextIO.outstream -> unit end
This module contains a bare minimum of functionality to do TCP/IP programming. This module is implemented on top of the Socket module of the Standard Basis Library. We encourage you to use the standard Socket module, since we may eliminate MLton.Socket some day.
-
type Address.t
-
Ctl.getERROR s
-
Host.getByAddress a
-
Host.getByName s
-
type Port.t
-
type t
-
accept s
-
connect (h, p)
-
fdToSock fd
-
listen ()
-
listenAt p
-
shutdownRead ins
-
shutdownWrite out
-
the type of IP addresses.
-
like the Basis Library's Socket.Ctl.getERROR, except that it returns more information. NONE means that there was no error, and SOME means that there was an error, and provides the error message and error code, if any.
-
looks up the hostname (using gethostbyaddr) corresponding to a.
-
looks up the hostname (using gethostbyname) corresponding to s.
-
the type of TCP ports.
-
the type of sockets.
-
accepts a connection on socket s and return the address and port of the connecting socket, as well as streams corresponding to the connection.
-
connects to host h on port p, returning the streams corresponding to the connection.
-
coerces a file descriptor to a socket.
-
listens to a port chosen by the system. Returns the port and the socket.
-
listens to port p. Returns the socket.
-
causes the read part of the socket associated with ins to be shutdown.
-
causes the write part of the socket associated with out to be shutdown.