TCP(7) — Silicon Graphics
NAME
tcp − Internet Transmission Control Protocol
SYNOPSIS
#include <sys/socket.h>
#include <net/in.h>
struct sockproto proto = { PF_INET, IPPROTO_TCP };
socket(SOCK_STREAM, &proto, address, options);
struct sockaddr_in *address; int options;
DESCRIPTION
The TCP protocol provides reliable, flow-controlled, two-way data tramission. It is a byte-stream protocol supporting SOCK_STREAM. TCP uses the standard Internet address format and provides a per-host collection of "port addresses". Thus, each address is an Internet address specifying the host and network, with a specific TCP port on the host identifying the peer entity.
Sockets using the TCP protocol are either "active" or "passive". Active sockets initiate connections to passive sockets. By default TCP sockets are created active; to create a passive socket SO_ACCEPTCONN must be used. Only passive sockets may use the accept(3N) call to accept incoming connections. Only active sockets may use the connect(3N) call to initiate connections.
Passive sockets may "underspecify" their location to match incoming connection requests from multiple networks ("wildcard addressing"). Thus a single server can service clients on multiple networks. To create a socket which can listen to all networks, the Internet address INADDR_ANY should be used.
The TCP port may still be specified at this time; if not, the system assigns one. Once a connection has been established, the socket’s address is fixed by the peer entity’s location. The address associated with network interface where packets are being transmitted and received is assigned to the socket. Normally this address corresponds to the peer entity’s network.
OPTIONS
The TCP implementation supports one non-standard feature: "keep-alives." Keep-alives check if a peer entity is still functional. They are enabled by creating a socket with the SO_KEEPALIVE option. They periodically poll the remote machine if the connection has been idle. Keep-alive packets are transmitted on a connection which has been idle for longer than 1 minute. If there is no response within 4 minutes the connection is aborted.
This only applies to an "established" connection; if a connection is not established and is idle for 1 minute it is aborted.
Note
TCP implementations which do not closely follow the TCP specification may not respond to keep-alive messages, causing connections to be closed without reason.
DIAGNOSTICS
EISCONN--trying to establish a connection on an already connected socket;
ENOBUFS--does not have memory for an internal data structure;
ETIMEDOUT--the connection was dropped due to excessive retransmissions;
ECONNRESET--the remote peer forces the connection to be closed;
ECONNREFUSED--the remote peer actively refuses to establish a connection (usually because no process is listening to the port);
EADDRINUSE--attempted to create a socket on an already allocated port.
EADDRNOTAVAIL--attempted to create a socket with an invalid network interface.
SEE ALSO
BUGS
Value added "features" such as "keep-alives" are experimental and not part of the protocol standard.
Version 2.3 — July 04, 1985