MLtonSocket - MLton Standard ML Compiler (SML Compiler)

MLton MLTONWIKIVERSION | MLtonSocket |
Home Index

    signature MLTON_SOCKET =
       sig
          structure Address:
             sig
                type t = NetHostDB.in_addr
             end
          structure Ctl:
             sig
                val getERROR: ('af, 'sock_type) Socket.sock -> (string * Posix.Error.syserror 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 listen: unit -> Port.t * t
          val listenAt: Port.t -> t
          val shutdownRead: TextIO.instream -> unit
          val shutdownWrite: TextIO.outstream -> unit

          val fdToSock: Posix.FileSys.file_desc -> ('a, 'b) Socket.sock
       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 Basis Library. We encourage you to use the standard `Socket` module, since `MLton.Socket` is deprecated.

- `type Address.t`
  the type of IP addresses.

- `Ctl.getERROR s`
  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.

- `Host.getByAddress a`
  looks up the hostname (using `gethostbyaddr`) corresponding to `a`.

- `Host.getByName s`
  looks up the hostname (using `gethostbyname`) corresponding to `s`.

- `type Port.t`
  the type of TCP ports.

- `type t`
  the type of sockets.

- `accept s`
  accepts a connection on socket `s` and return the address port of the connecting socket, as well as streams corresponding to the connection.

- `connect (h, p)`
  connects to host `h` on port `p`, returning the streams corresponding to the connection.

- `listen ()`
  listens to a port chosen by the system. Returns the port and the socket.

- `listenAt p`
  listens to port `p`. Returns the socket.

- `shutdownRead ins`
  causes the read part of the socket associated with `ins` to be shutdown.

- `shutdownWrite out`
  causes the write part of the socket associated with `out` to be shutdown.

- `fdToSock fd`
  coerces a file descriptor to a socket.

Last edited on 2007-08-23 03:45:24 by MatthewFluet.