Book contents
- Frontmatter
- Contents
- Foreword by Robin Milner
- Preface
- 1 Introduction
- 2 Library modules
- 3 Top-level environment
- 4 General usages
- 5 Text
- 6 Numerics
- 7 Sequential data
- 8 Input/Output
- 9 Systems programming
- 10 Network programming with sockets
- 11 Manual pages
- Bibliography
- General index
- SML identifier index
- Raised exception index
10 - Network programming with sockets
Published online by Cambridge University Press: 05 August 2012
- Frontmatter
- Contents
- Foreword by Robin Milner
- Preface
- 1 Introduction
- 2 Library modules
- 3 Top-level environment
- 4 General usages
- 5 Text
- 6 Numerics
- 7 Sequential data
- 8 Input/Output
- 9 Systems programming
- 10 Network programming with sockets
- 11 Manual pages
- Bibliography
- General index
- SML identifier index
- Raised exception index
Summary
Overview
Sockets are an abstraction for interprocess communication (IPC) that were introduced as part of the Berkeley version of Unix in 1982. They have become a de facto standard for network communication and are supported by most major operating systems (including PC systems). The SML Basis Library provides an optional collection of modules for programming with sockets. The interface provided by the Basis follows the C interface for the most part; the major difference is that the SML interface is more strongly typed. In particular, the type system distinguishes between passive and active sockets, between sockets in different domains, and between sockets of different protocols.
The Berkeley Socket API supports two styles of communication: stream sockets provide virtual circuits between pairs of processes, and datagram sockets provide connectionless packet-based communication. In stream-based interactions, the server allocates a master socket that is used to accept connections from clients. The server then listens on the master socket for connection requests from clients; each request is allocated a new socket that the server uses to communicate with that particular client. As the name suggests, stream-based communication is done as a stream of bytes, not as discrete packets. Connectionless communication is more symmetric: messages are sent to a specific port at a specific address. While datagram sockets provide better performance, messages may be lost or received out of order, which requires additional programming by the client. For this reason, stream sockets are more commonly used than datagram sockets.
- Type
- Chapter
- Information
- The Standard ML Basis Library , pp. 99 - 110Publisher: Cambridge University PressPrint publication year: 2004