Skip to main content Accessibility help
×
Hostname: page-component-848d4c4894-x5gtn Total loading time: 0 Render date: 2024-06-02T16:12:28.076Z Has data issue: false hasContentIssue false

10 - Network programming with sockets

Published online by Cambridge University Press:  05 August 2012

Emden R. Gansner
Affiliation:
AT&T Bell Laboratories, New Jersey
John H. Reppy
Affiliation:
University of Chicago
Get access

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
Publisher: Cambridge University Press
Print publication year: 2004

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×