5.1 Sockets in a Nutshell

A socket is a data structure which can be used for communication between operating system processes on possibly different computers connected by a network.

5.1.1 Domain

Unix based operating systems offers two domains for sockets: The Internet domain and the Unix domain. The first can be used for communication all over the world, whereas the latter is only applicable within one Unix system. Other systems might offer only sockets for the Internet domain. Mozart supports sockets for the Internet domain.

5.1.2 Type

Sockets we are going to describe here are either of type stream or of type datagram . There are more than these types of sockets, which are used by the operating system internally for implementing stream and datagram sockets themselves. See for instance socket(2).

A stream socket is connection-oriented: Two processes establish a one-to-one connection in using a socket. After the connection has been established a stream socket has the following features:

  1. Stream oriented: Character codes are incrementally sent and received.

  2. Duplex: Both processes have sending and receiving access to the stream. The data passed are bytes, i. e. small integers between 0 and 255.

  3. Reliability: No data will be lost in most cases.

  4. Sequencing: The order of data sent will not be changed.

A datagram has only the feature of being duplex: It provides no reliability and no sequencing (messages may arrive in any order). It supports sending and receiving data packets of a (usually) small size.

5.1.3 Protocol

The protocol of a socket gives services used for performing communication on it. For example, the usual protocols for the Internet domain are TCP (Internet Transmission Control Protocol) for stream sockets and UDP (Internet User Datagram Protocol) for datagram sockets.

Christian Schulte
Version 1.4.0 (20080702)