The Standard ML Basis Library


The UnixSock structure


Synopsis

signature UNIX_SOCK  (* OPTIONAL *)
structure UnixSock :> UNIX_SOCK  (* OPTIONAL *)

This structure is used to create sockets in the Unix address family. This structure is only present when the underlying operating system supports Unix-domain sockets.

Binding a name to a Unix-domain socket with bind causes a socket file to be created in the filesystem. This file is not removed when the socket is closed; OS.FileSys.remove must be used to remove the file. The usual filesystem access-control mechanisms are applied when referencing Unix-domain sockets; e.g., the file representing the destination of a connect or sendVec must be writable.


Interface

type unix
type 'sock_type sock = (unix, 'sock_type) Socket.sock
type 'mode stream_sock = 'mode Socket.stream sock
type dgram_sock = Socket.dgram sock
type sock_addr = unix Socket.sock_addr
val unixAF : Socket.AF.addr_family
val toAddr : string -> sock_addr
val fromAddr : sock_addr -> string
structure Strm : sig
    val socket : unit -> 'mode stream_sock
    val socketPair : unit
                       -> 'mode stream_sock
                       * 'mode stream_sock
  end
structure DGrm : sig
    val socket : unit -> dgram_sock
    val socketPair : unit -> dgram_sock * dgram_sock
  end

Description

type unix
The witness type of the Unix address family.

type 'sock_type sock = (unix, 'sock_type) Socket.sock
The type-scheme for all Unix-domain sockets.

type 'mode stream_sock = 'mode Socket.stream sock
The type-scheme of Unix-domain (passive or active) stream sockets.

type dgram_sock = Socket.dgram sock
The type of Unix-domain datagram sockets.

type sock_addr = unix Socket.sock_addr
The type of a Unix-domain socket address.

val unixAF : Socket.AF.addr_family
The Unix address family value.

toAddr s
converts a pathname s into a socket address (in the Unix address family); it does not check the validity of the path s.

fromAddr addr
returns the Unix file system path corresponding to the Unix-domain socket address addr.

structure Strm

val socket : unit -> 'mode stream_sock
This function creates a stream socket in the Unix address family. It raises SysErr if there are too many sockets in use.

val socketPair : unit
                   -> 'mode stream_sock * 'mode stream_sock
This function creates an unnamed pair of connected stream sockets in the Unix address family. It is similar to the Posix.IO.pipe function in that the returned sockets are connected, but unlike pipe, the sockets are bidirectional. It raises SysErr if there are too many sockets in use.

structure DGrm

val socket : unit -> dgram_sock
This function creates a datagram socket in the Unix address family. It raises SysErr if there are too many sockets in use.

val socketPair : unit -> dgram_sock * dgram_sock
This function creates an unnamed pair of connected datagram sockets in the Unix address family. It raises SysErr if there are too many sockets in use.

See Also

GenericSock, INetSock, Socket

[ Top | Parent | Contents | Index | Root ]

Generated April 12, 2004
Last Modified June 5, 1998
Comments to John Reppy.


This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.

Copyright © 2004 AT&T and Lucent Technologies. All rights reserved.

Permission is granted for internet users to make one paper copy for their own personal use. Further hardcopy reproduction is strictly prohibited. Permission to distribute the HTML document electronically on any medium other than the internet must be requested from the copyright holders by contacting the editors. Printed versions of the SML Basis Manual are available from Cambridge University Press. To order, please visit www.cup.org (North America) or www.cup.cam.ac.uk (outside North America).