next up previous contents
Next: MLton.Syslog Up: MLton Previous: MLton.Signal   Contents

MLton.Socket

This module contains a bare minimum of functionality to do TCP/IP programming. This module may disappear after the Socket module of the standard basis library becomes available. Or, it may remain and be implemented on top of that module.
signature MLTON_SOCKET =
   sig
      structure Address:
         sig
            type t = word
         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
   end

type Address.t

the type of IP addresses.

Host.getByAddress a

lookup the hostname (using gethostbyaddr) corresponding to a.

Host.getByName s

lookup the hostname (using gethostbyname) corresponding to s.

type Port.t

the type of TCP ports.

type t

the type of sockets.

accept s

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

connect (h, p)

connect to host h on port p, returning the streams corresponding to the connection.

listen ()

listen to a port chosen by the system. Returns the port and the socket.

listenAt p

listen to port p. Returns the socket.

shutdownRead ins

cause the read part of the socket associated with ins to be shutdown.

shutdownWrite out

cause the write part of the socket associated with out to be shutdown.


next up previous contents
Next: MLton.Syslog Up: MLton Previous: MLton.Signal   Contents