HP-UX Reference (11i v2 03/08) - 5 Miscellaneous Topics, 7 Device (Special) Files, 9 General Information, Index (vol 9)

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
connections 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 sock-
ets 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.
The system supports four socket options:
TCP_MAXSEG, TCP_NODELAY, TCP_ABORT_THRESHOLD
,
and
TCP_CONN_ABORT_THRESHOLD
(defined in the include file <netinet/tcp.h>). TCP_MAXSEG
option can only be used with getsockopt(), while TCP_NODELAY, TCP_ABORT_THRESHOLD
, and
TCP_CONN_ABORT_THRESHOLD
can be set with setsockopt() and tested with getsockopt()
(see getsockopt (2)). These four 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
establishment. The option value is the threshold time in milliseconds.
This option is the same as
TCP_ABORT_THRESHOLD, except that this
value is used during connection establishment. When it must retransmit
the SYN packet because a timer has expired, TCP first compares the
total time it has waited against the two thresholds. If it has waited
HP-UX 11i Version 2: August 2003 − 1 − Hewlett-Packard Company Section 7−−171