Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tcp(7) — OSF/1 3.0 αXP

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getsockopt(2)

socket(2)

netintro(7)

inet(7)

ip(7)

tcp(7)  —  Special Files

NAME

tcp − Internet Transmission Control Protocol (TCP)

SYNOPSIS

#include <sys/socket.h>
#include <netinet/in.h>

s = socket(AF_INET, SOCK_STREAM, 0);

DESCRIPTION

The TCP protocol provides reliable, flow-controlled, two-way transmission of data.  It is a byte-stream protocol used to support the SOCK_STREAM abstraction.  The TCP protocol uses the standard Internet address format and, in addition, provides a per-host collection of port addresses.  Thus, each address is composed of an Internet address specifying the host and network, with a specific TCP port on the host identifying the peer entity. 

Sockets utilizing the TCP are either active or passive.  Active sockets initiate connections to passive sockets.  By default, TCP sockets are created active; to create a passive socket the listen function must be used after binding the socket with the bind function.  Only passive sockets may use the accept function to accept incoming connections.  Only active sockets may use the connect function to initiate connections. 

Passive sockets may underspecify their location to match incoming connection requests from multiple networks.  This technique, termed wildcard addressing, allows a single server to provide service to clients on multiple networks.  To create a socket which listens on all networks, the Internet address INADDR_ANY must be bound.  The TCP port may still be specified at this time; if the port is not specified the system will assign one.  Once a connection has been established, the socket’s address is fixed by the peer entity’s location.   The address assigned to the socket is the address associated with the network interface through which packets are being transmitted and received.  Normally this address corresponds to the peer entity’s network. 

TCP supports the following socket options: TCP_MAXSEG and TCP_NODELAY. Both can be retrieved with the getsockopt function and set with the setsockopt function.  Under most circumstances, TCP sends data when it is presented; when outstanding data has not yet been acknowledged, it gathers small amounts of output to be sent in a single packet once an acknowledgement is received.  For a small number of clients, such as window systems that send a stream of mouse events which receive no replies, this gathering of output may cause significant delays.  Therefore, TCP provides a Boolean option, TCP_NODELAY (from the netinet/tcp.h header file), to defeat this algorithm. 

The maximum size of a TCP segment is based on the network MTU for destinations on local networks or on a default MTU of 576 bytes for destinations on nonlocal networks.  The default behavior can be altered by setting the TCP_MAXSEG option to an integer value from 1 to 65,535.  However, TCP will not use a maximum segment size smaller than 32 or larger than the local network MTU.  Setting the TCP_MAXSEG option to a value of zero results in default behavior.  The TCP_MAXSEG option can only be set prior to calling listen or connect on the socket. 

The option level for the setsockopt and getsockopt functions is the protocol number for TCP, available from the getprotobyname function. 

Options at the IP transport level may be used with TCP; see ip(7).  Incoming connection requests that are source-routed are noted, and the reverse source route is used in responding. 

ERRORS

If a socket operation fails, errno may be set to one of the following values:

[EINVAL]The option_len parameter provided to the setsockopt or getsockopt function is less than sizeof(int) or the option_len parameter provided to the setsockopt function for the TCP_MAXSEG option is not in the range or 0 to 65,535. 

[EISCONN]The socket to be connected already has a connection. 

[ENOBUFS]The system ran out of memory for an internal data structure. 

[EOPNOTSUPP]
Setting the TCP_MAXSEG option is not supported after connect or listen. 

[ETIMEDOUT]
A connection was dropped due to excessive retransmissions.

[ECONNRESET]
The remote peer forced the connection to be closed.

[ECONNREFUSED]
The remote peer actively refuses connection establishment (usually because no process is listening to the port).

[EADDRINUSE]
An attempt is made to create a socket with a port which has already been allocated.

[EADDRNOTAVAIL]
An attempt is made to create a socket with a network address for which no network interface exists.

RELATED INFORMATION

Functions: getsockopt(2), socket(2)

Network Information: netintro(7), inet(7), ip(7)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026