tcp.7p (2010 09)
t
TCP(7P) TCP(7P)
NAME
TCP - Internet Transmission Control Protocol
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
s = socket(AF_INET, SOCK_STREAM, 0);
s = socket(AF_INET6, 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 socket type. TCP constructs virtual circuits between peer
entities. A virtual circuit consists of remote Internet addresses, remote ports, local Internet addresses
and local ports. IP uses the Internet addresses to direct messages between hosts, and the port numbers to
identify a TCP entity at a particular host.
Sockets using TCP are either active or passive.
connect() creates active sockets, which initiate con-
nections to passive sockets (see connect (2)). To create a passive socket, use the
listen() system call
after binding the socket with the
bind() system call (see listen (2) and bind(2)). Only passive sockets
can use the
accept() call to accept incoming connections (see accept (2)).
Passive sockets can underspecify their location to match incoming connection requests from multiple net-
works. This technique, called wildcard addressing, allows a single server to provide service to clients
on multiple networks. To create a socket that listens on all networks, the Internet address
INADDR_ANY
must be bound for AF_INET family and in6addr_any for AF_INET6 family. The TCP port can still be
specified even if wildcard addressing is being used. If the port is specified as zero, the system assigns a
port.
Once
accept() has a rendezvous with a connect request, a virtual circuit is established between peer
entities. bind() supplies the local port and local Internet address and accept() gathers the remote
port and remote Internet address from the peer requesting the connection.
Options
The system supports the following socket options:
TCP_MAXSEG, TCP_NODELAY,
TCP_ABORT_THRESHOLD
, TCP_CONN_ABORT_THRESHOLD, TCP_KEEPCNT, TCP_KEEPIDLE,
TCP_KEEPINTVL, TCP_TSOPTENA, and
TCP_SACKENA (defined in the include file
<netinet/tcp.h>).
The
TCP_MAXSEG option can only be used with getsockopt(), while TCP_NODELAY,
TCP_ABORT_THRESHOLD
, TCP_CONN_ABORT_THRESHOLD TCP_KEEPCNT, TCP_KEEPIDLE,
TCP_KEEPINTVL, TCP_TSOPTENA, and
TCP_SACKENA can be set with setsockopt() and tested
with
getsockopt() (see getsockopt (2)). These options require level to be set to IPPROTO_TCP in the
getsockopt/setsockopt
call.
TCP_MAXSEG (non-boolean option) lets an application to receive the current segment size of the
TCP SOCK_STREAM socket. The current segment size will be returned in optval .
TCP_NODELAY
(boolean option) causes small amounts of output to be sent immediately.
TCP_ABORT_THRESHOLD
(non-boolean option) sets the second threshold timer for the connections that are in
ESTABLISHED state. The option value is the threshold time in milliseconds.
When it must retransmit packets because a timer has expired, TCP first compares
the total time it has waited against the two thresholds, as described in RFC 1122,
4.2.3.5. If it has waited longer than the second threshold (R2), TCP terminates the
connection. The default value for this option is the current value of the ndd tunable
parameter
tcp_ip_abort_interval. Refer to ndd(1M) online help for details
on the tcp_ip_abort_interval default value.
TCP_CONN_ABORT_THRESHOLD
(non-boolean option) sets the second threshold timer during connection establish-
ment. The option value is the threshold time in milliseconds.
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1