TCP(4P) Series 300 Only TCP(4P)
NAME
tcp - Internet Transmission Control Protocol
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_STREAM, 0);
HP-UX COMPATIBILITY
Level: HP-UX/NON-STANDARD
Origin: UCB
Remarks: Implemented on the Series 300 only.
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 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 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 the listen(2) system call must be
used after binding the socket with the bind(2) system call.
Only passive sockets may use the accept(2) call to accept
incoming connections. Only active sockets may use the
connect(2) call 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. Using wildcard
addressing is not necessary for this implementation, since
only one network connection is supported. Wildcard
addressing is, however, recommended as good practice so that
applications may more easily port to systems which do
support multiple network connections. The TCP port may
still be specified even if wildcard addressing is being
used. If the port is specified as zero the system will
assign one. Once a connection has been established, the
accept(2) socket's address is fixed by the peer entity's
address. The address assigned the socket is the address
associated with the network interface through which packets
Hewlett-Packard - 1 - (printed 7/16/86)
TCP(4P) Series 300 Only TCP(4P)
are being transmitted and received. Normally this address
corresponds to the peer entity's network.
There are some TCP level options which may be accessed
through setsockopt(2) and getsockopt(2). The options are
defined in <sys/socket.h>.
TCP_PRECEDENCE set precedence level for this
connection
TCP_SECURITY set security level for this
connection
To access these options, the level parameter should be set
to the protocol number for TCP; see getprotoent(3N) and
getsockopt(2). These parameters allow the precedence and
security of a TCP connection to be controlled. The
setsockopt(2) call to set these parameters must be issued
prior to the connect(2) call for an active socket, and prior
to the listen(2) call for the passive socket. The
getsockopt(2) call may be done at any time.
TCP_PRECEDENCE takes a one-byte option value. It allows
setting the precedence portion of the type-of-service field
within the IP header. The value of the precedence field, is
governed by the DARPA Internet Protocol specification and
must be in the range 0 through 7. When TCP establishes a
connection, the precedence portion of the type-of-service
field of the sockets on each end must match exactly, or the
connection will not be made. If a packet arrives with a
different precedence after the connection has been
established, the connection will be dropped. The default
value is zero if the TCP_PRECEDENCE option is not specified.
An attempt to change the type-of-service field after the
connection has been established will result in an EISCONN
error.
TCP_SECURITY allows control of the security option in an IP
header. The nine bytes specified in the optval parameter
represent the nine bytes of security information in the
header. No security information is the default. The first
two bytes of the option define the security level for the
connection. The next two bytes define the compartmentation
for the connection. The next two bytes define the handling
restrictions, while the last three bytes define the
transmission control code. The allowable values and their
meanings for all of these fields are governed by the DARPA
Internet Protocal specification and various Department of
Defense regulations. A TCP connection will only be
established if the sockets on both ends of the connection
have identical security option settings, and will
immediately be dropped if packet with mismatched security
arrives. An attempt to change the TCP_SECURITY option after
Hewlett-Packard - 2 - (printed 7/16/86)
TCP(4P) Series 300 Only TCP(4P)
the connection has been established will result in an
EISCONN error.
A socket operation may fail with one of the following errors
returned. See the manual page for the specific operation
for a more complete and specific list of errors.
[EISCONN] when trying to establish a
connection on a socket which
already has one; or trying to do an
operation on a connected socket
which can only be done on one that
has not yet been connected;
[ENOBUFS] when the system runs out of memory
for an internal data structure;
[ETIMEDOUT] when a connection was dropped due
to excessive retransmissions;
[ECONNRESET] when the remote peer forces the
connection to be closed;
[ECONNREFUSED] when the remote peer actively
refuses connection establishment
(usually because no process is
listening to the port);
[EADDRINUSE] when an attempt is made to create a
socket with a port which has
already been allocated;
[EADDRNOTAVAIL] when an attempt is made to create a
socket with a network address for
which no network interface exists.
[ENET] when a hardware error is detected
on the interface card.
SEE ALSO
socket(2), inet(4F).
Hewlett-Packard - 3 - (printed 7/16/86)