The Standard ML Basis Library


The INetSock structure


Synopsis

signature INET_SOCK  (* OPTIONAL *)
structure INetSock :> INET_SOCK  (* OPTIONAL *)

This structure provides operations for creating and manipulating Internet-domain addresses and sockets.


Interface

type inet
type 'sock_type sock = (inet, 'sock_type) Socket.sock
type 'mode stream_sock = 'mode Socket.stream sock
type dgram_sock = Socket.dgram sock
type sock_addr = inet Socket.sock_addr
val inetAF : Socket.AF.addr_family
val toAddr : NetHostDB.in_addr * int -> sock_addr
val fromAddr : sock_addr -> NetHostDB.in_addr * int
val any : int -> sock_addr
structure UDP : sig
    val socket : unit -> dgram_sock
    val socket' : int -> dgram_sock
  end
structure TCP : sig
    val socket : unit -> 'mode stream_sock
    val socket' : int -> 'mode stream_sock
    val getNODELAY : 'mode stream_sock -> bool
    val setNODELAY : 'mode stream_sock * bool -> unit
  end

Description

type inet
The witness type of the INet address family.

type 'mode stream_sock = 'mode Socket.stream sock
The type-scheme of Internet-domain stream sockets; The type parameter 'mode can be instantiated to either Socket.active or Socket.passive.

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

type sock_addr = inet Socket.sock_addr
The type of Internet-domain socket addresses.

val inetAF : Socket.AF.addr_family
The address family value that represents the Internet domain.

toAddr (ia, i)
converts an Internet address ia and a port number i into a socket address (in the INet address family).

val fromAddr : sock_addr -> NetHostDB.in_addr * int
This function converts a socket address (in the INet address family) into a pair (ia,i) of an Internet address ia and a port number i.

any port
creates a socket address that fixes the port to port, but leaves the Internet address unspecified. This function corresponds to the INADDR_ANY constant in the C Sockets API. The values created by this function are used to bind a socket to a specific port.

structure UDP

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

socket' prot
creates a datagram socket in the INet address family with the protocol number prot. The interpretation of prot is system dependent, but a value of 0 is equivalent to socket(). It raises SysErr if there are too many sockets in use.

structure TCP

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

socket' prot
creates a stream socket in the INet address family with the protocol number prot. The interpretation of prot is system dependent, but a value of 0 is equivalent to socket().

val getNODELAY : 'mode stream_sock -> bool
val setNODELAY : 'mode stream_sock * bool -> unit
These functions query and set the TCP_NODELAY flag on the socket. When set to false (the default), there is only a single small packet allowed to be outstanding on a given TCP connection at any time, thereby reducing small packet traffic on slower WANs. When set to true, packets are sent as fast as possible. [[Refer to Stevens, p.316.]]

See Also

GenericSock, NetHostDB, Socket, UnixSock

[ Top | Parent | Contents | Index | Root ]

Generated October 02, 2003
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 © 2003 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).