TCP(7P) — Series 300 and 800 Only
NAME
TCP − Internet Transmission Control Protocol
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 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(2) creates active sockets, which initiate connections to passive sockets. To create a passive socket, use the listen(2) system call after binding the socket with the bind(2) system call. Only passive sockets can use the accept(2) call to accept incoming connections.
Passive sockets can underspecify their location to match incoming connection requests from multiple networks. 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. 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 for you.
Once accept(2) has a rendezvous with a connect request, a virtual circuit is established between peer entities. Bind(2) supplies the local port and local internet address and accept(2) gathers the remote port and remote internet address from the peer requesting the connection.
DIAGNOSTICS
One of the following errors may be returned if a socket operation fails. See the manual entry for the specific system call 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 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.
DEPENDENCIES
Implemented on the Series 300 and 800 only. This entry describes the use of the TCP protocol as it applies to the ARPA/Berkeley Services Interprocess Communication utility. It does not apply to the use of TCP for the LAN/9000 Series 800 NetIPC utility. Refer to the LAN/9000 Series 800 NetIPC Programmer’s Guide for information about NetIPC.
If the SO_KEEPALIVE option is set on an established TCP connection, and the connection is otherwise idle, TCP sends a packet to the remote socket, expecting the remote socket to acknowledge that it is still alive. If the remote socket does not respond within 45 seconds, TCP sends another packet. If TCP sends a total of 8 packets without response from the remote socket (that is, 6 minutes have passed), TCP drops the connection and returns the error ETIMEDOUT. Once the SO_KEEPALIVE option is set on a connection, it cannot be turned off. See getsockopt(2) for details on setting SO_KEEPALIVE.
The maximum buffer size for a TCP stream socket is 65535 bytes. The default buffer size is 4096 bytes. The send and receive buffer sizes for TCP stream sockets can be altered by the setsockopt(2) system call. Refer to getsockopt(2) for details.
AUTHOR
UCB (University of California at Berkeley)
SEE ALSO
getsockopt(2), socket(2), inet(7F).
Hewlett-Packard Company — May 11, 2021