![]() | Library Documentation | Structures | Signatures | Identifiers | Packages | About |
SOCKET (basis)Socket interface.
structure Socket : SOCKET (basis)
signature SOCKET = sig
type ('af,'st) sock
type 'af sock_addr
type 'm stream
type passive
type active
structure AF :
sig
eqtype addr_family
val list : unit -> (string * addr_family) list
val toString : addr_family -> string
val fromString : string -> addr_family option
end
structure SOCK :
sig
eqtype sock_type
val stream : sock_type
val dgram : sock_type
val list : unit -> (string * sock_type) list
val toString : sock_type -> string
val fromString : string -> sock_type option
end
structure Ctl :
sig
val getDEBUG : ('af, 'st) sock -> bool
val setDEBUG : ('af, 'st) sock * bool -> unit
val getREUSEADDR : ('af, 'st) sock -> bool
val setREUSEADDR : ('af,'st) sock * bool -> unit
val getKEEPALIVE : ('af, 'st) sock -> bool
val setKEEPALIVE : ('af, 'st) sock * bool -> unit
val getDONTROUTE : ('af, 'st) sock -> bool
val setDONTROUTE : ('af, 'st) sock * bool -> unit
(*
val getLINGER : ('af, 'st) sock -> Time.time option
val setLINGER : ('af, 'st) sock * Time.time option -> unit
*)
val getBROADCAST : ('af, 'st) sock -> bool
val setBROADCAST : ('af, 'st) sock * bool -> unit
val getOOBINLINE : ('af, 'st) sock -> bool
val setOOBINLINE : ('af, 'st) sock * bool -> unit
val getSNDBUF : ('af, 'st) sock -> int
val setSNDBUF : ('af, 'st) sock * int -> unit
val getRCVBUF : ('af, 'st) sock -> int
val setRCVBUF : ('af, 'st) sock * int -> unit
val getTYPE : ('af, 'st) sock -> SOCK.sock_type
val getERROR : ('af, 'st) sock -> bool
val getPeerName : ('af, 'st) sock -> 'af sock_addr
val getSockName : ('af, 'st) sock -> 'af sock_addr
(*
val getNREAD : ('af, 'st) sock -> int
val getATMARK : ('af, active stream) sock -> bool
*)
end
val sameAddr : 'af sock_addr * 'af sock_addr -> bool
val familyOfAddr : 'af sock_addr -> AF.addr_family
val bind : ('af, 'st) sock * 'af sock_addr -> unit
val listen : ('af, passive stream) sock * int -> unit
val accept : ('af, passive stream) sock -> ('af, active stream) sock * 'af sock_addr
(*
val acceptNB : ('af, passive stream) sock -> (('af, active stream) sock * 'af sock_addr) option
*)
val connect : ('af, 'st) sock * 'af sock_addr -> unit
(*
val connectNB : ('af, 'st) sock * 'af sock_addr -> bool
*)
val close : ('af, 'st) sock -> unit
datatype shutdown_mode
= NO_RECVS
| NO_SENDS
| NO_RECVS_OR_SENDS
val shutdown : ('af, 'mode stream) sock * shutdown_mode -> unit
type sock_desc
val sockDesc : ('af, 'st) sock -> sock_desc
val sameDesc : sock_desc * sock_desc -> bool
val select : { rds : sock_desc list,
wrs : sock_desc list,
exs : sock_desc list,
timeout : Time.time option
}
-> { rds : sock_desc list,
wrs : sock_desc list,
exs : sock_desc list
}
val ioDesc : ('af, 'st) sock -> OS.IO.iodesc
type out_flags = {don't_route : bool, oob : bool}
type in_flags = {peek : bool, oob : bool}
val sendVec : ('af, active stream) sock * Word8VectorSlice.slice -> int
val sendArr : ('af, active stream) sock * Word8ArraySlice.slice -> int
(*
val sendVec' : ('af, active stream) sock * Word8VectorSlice.slice * out_flags -> int
val sendArr' : ('af, active stream) sock * Word8ArraySlice.slice * out_flags -> int
val sendVecNB : ('af, active stream) sock * Word8VectorSlice.slice -> int option
val sendVecNB' : ('af, active stream) sock * Word8VectorSlice.slice * out_flags -> int option
val sendArrNB : ('af, active stream) sock * Word8ArraySlice.slice -> int option
val sendArrNB' : ('af, active stream) sock * Word8ArraySlice.slice * out_flags -> int option
*)
val recvVec : ('af, active stream) sock * int -> Word8Vector.vector
(*
val recvVec' : ('af, active stream) sock * int * in_flags -> Word8Vector.vector
val recvArr : ('af, active stream) sock * Word8ArraySlice.slice -> int
val recvArr' : ('af, active stream) sock * Word8ArraySlice.slice * in_flags -> int
val recvVecNB : ('af, active stream) sock * int -> Word8Vector.vector option
val recvVecNB' : ('af, active stream) sock * int * in_flags -> Word8Vector.vector option
val recvArrNB : ('af, active stream) sock * Word8ArraySlice.slice -> int option
val recvArrNB' : ('af, active stream) sock * Word8ArraySlice.slice * in_flags -> int option
val sendVecTo : ('af, dgram) sock * 'af sock_addr * Word8VectorSlice.slice -> unit
val sendArrTo : ('af, dgram) sock * 'af sock_addr * Word8ArraySlice.slice -> unit
val sendVecTo' : ('af, dgram) sock * 'af sock_addr * Word8VectorSlice.slice * out_flags -> unit
val sendArrTo' : ('af, dgram) sock * 'af sock_addr * Word8ArraySlice.slice * out_flags -> unit
val sendVecToNB : ('af, dgram) sock * 'af sock_addr * Word8VectorSlice.slice -> bool
val sendVecToNB' : ('af, dgram) sock * 'af sock_addr * Word8VectorSlice.slice * out_flags -> bool
val sendArrToNB : ('af, dgram) sock * 'af sock_addr * Word8ArraySlice.slice -> bool
val sendArrToNB' : ('af, dgram) sock * 'af sock_addr * Word8ArraySlice.slice * out_flags -> bool
val recvVecFrom : ('af, dgram) sock * int -> Word8Vector.vector * 'st sock_addr
val recvVecFrom' : ('af, dgram) sock * int * in_flags -> Word8Vector.vector * 'st sock_addr
val recvArrFrom : ('af, dgram) sock * Word8ArraySlice.slice -> int * 'af sock_addr
val recvArrFrom' : ('af, dgram) sock * Word8ArraySlice.slice * in_flags -> int * 'af sock_addr
val recvVecFromNB : ('af, dgram) sock * int -> (Word8Vector.vector * 'st sock_addr) option
val recvVecFromNB' : ('af, dgram) sock * int * in_flags ->
(Word8Vector.vector * 'st sock_addr) option
val recvArrFromNB : ('af, dgram) sock * Word8ArraySlice.slice -> (int * 'af sock_addr) option
val recvArrFromNB' : ('af, dgram) sock * Word8ArraySlice.slice * in_flags
-> (int * 'af sock_addr) option
*)
end
[list()] This function returns a list of all the available address
families. Every element of the list is a pair (name,af) where name
is the name of the address family, and af is the actual address
family value.
The names of the address families are taken from the symbolic
constants used in the C Socket API and stripping the leading
``AF_.'' For example, the Unix-domain address family is named
"UNIX", the Internet-domain address family is named "INET", and
the Apple Talk address family is named "APPLETALK".
[toString addr_family]
[fromString s]
These functions convert between address family values and their
names. For example, the expression toString (INetSock.inetAF)
returns the string "INET". fromString returns NONE if no family
value corresponds to the given name.
If a pair (name,af) is in the list returned by list, then it is
the case that name is equal to toString(af).
[eqtype sock_type] The type of socket types.
[stream] The stream socket type value.
[dgram] The datagram socket type value.
[list()] Returns a list of the available socket types. Every
element of the list is of the form (name,sty) where name is the
name of the socket type, and sty is the actual socket type value.
The list of possible socket type names includes "STREAM" for
stream sockets, "DGRAM" for datagram sockets, and "RAW" for raw
sockets. These names are formed by taking the symbolic constants
from the C API and removing the leading ``SOCK_.''
[toString sock_type]
[fromString s]
These functions convert between a socket type value and its name
(e.g., "STREAM"). fromString returns NONE if no socket type value
corresponds to the name.
If a pair (name,sty) is in the list returned by list, then it is the
case that name is equal to toString(sty).
[getDEBUG s]
[setDEBUG (s, b)]
These functions query and set the SO_DEBUG flag for the
socket. This flag enables or disables low-level debugging within
the kernel. Enabled, it allows the kernel to maintain a history
of the recent packets that have been received or sent.
[getREUSEADDR s]
[setREUSEADDR (s, b)]
These functions query and set the SO_REUSEADDR flag for the
socket. When true, this flag instructs the system to allow reuse
of local socket addresses in bind calls.
[getKEEPALIVE s]
[setKEEPALIVE (s, b)]
These functions query and set the SO_KEEPALIVE flag for the
socket. When true, the system will generate periodic transmissions
on a connected socket, when no other data is being exchanged.
[getDONTROUTE s]
[setDONTROUTE (s, b)]
These functions query and set the SO_DONTROUTE flag for the
socket. When this flag is true, outgoing messages bypass the
normal routing mechanisms of the underlying protocol, and are
instead directed to the appropriate network interface as specified
by the network portion of the destination address. Note that this
option can be specified on a per message basis by using one of the
sendVec', sendArr', sendVecTo', or sendArrTo' functions.
[getLINGER s]
[setLINGER (s, t)]
These functions query and set the SO_LINGER flag for the socket
sock. This flag controls the action taken when unsent messages
are queued on socket and a close is performed. If the flag is set
to NONE, then the system will close the socket as quickly as
possible, discarding data if necessary. If the flag is set to
SOME(t) and the socket promises reliable delivery, then the system
will block the close operation until the data is delivered or the
timeout t expires. If t is negative or too large, then the Time is
raised.
[getBROADCAST s]
[setBROADCAST (s, b)]
These functions query and set the SO_BROADCAST flag for the socket
sock, which enables or disables the ability of the process to send
broadcast messages over the socket.
[getOOBINLINE s]
[setOOBINLINE (s, b)]
These functions query and set the SO_OOBINLINE flag for the
socket. When set, this indicates that out-of-band data should be
placed in the normal input queue of the socket. Note that this
option can be specified on a per message basis by using one of the
sendVec', sendArr', sendVecTo', or sendArrTo' functions.
[getSNDBUF s]
[setSNDBUF (s, i)]
These functions query and set the size of the send queue buffer
for the socket.
[getRCVBUF s]
[setRCVBUF (s, i)]
These functions query and set the size of receive queue buffer for
the socket.
[getTYPE s] This function returns the socket type of the socket.
[getERROR s] This function indicates whether or not an error has
occurred.
[getPeerName s] This function returns the socket address to which
the socket is connected.
[getSockName s] This function returns the socket address to which
the socket is bound.
[getNREAD s] This function returns the number of bytes available
for reading on the socket.
[getATMARK s] This function indicates whether or not the read
pointer on the socket is currently at the out-of-band mark.