Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ tcp(ADMP) — OpenDesktop 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getsockopt(SSC)

ifconfig(ADMN)

inet(ADMP)

Intro(ADMP)

ip(ADMP)

vice(F)

socket(SSC)


 tcp(ADMP)                       19 June 1992                       tcp(ADMP)


 Name

    tcp - Internet Transmission Control Protocol

 Syntax

    Programmer's interface:
    #include  <sys/socket.h>
    #include  <netinet/in.h>

    s = socket(AFINET, SOCKSTREAM, 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
    abstraction.  TCP uses the standard Internet address format and, in addi-
    tion, provides a per-host collection of ``port addresses''.  Thus, each
    address is composed of an Internet address specifying the host and net-
    work, 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 the listen(SSC)
    system call must be used after binding the socket with the bind(SSC) sys-
    tem call.  Only passive sockets may use the accept(SSC) call to accept
    incoming connections.  Only active sockets may use the connect(SSC) call
    to initiate connections.

    Passive sockets may ``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
    may still be specified at this time; if the port is not specified the
    system will assign one.  Once a connection has been established the
    socket's address is fixed by the peer entity's location.   The address
    assigned the socket is the address associated with the network interface
    through which packets are being transmitted and received.  Normally this
    address corresponds to the peer entity's network.

    TCP supports one socket option which is set with setsockopt and tested
    with getsockopt (see getsockopt(SSC)).  Under most circumstances, TCP
    sends data when it is presented; when outstanding data has not yet been
    acknowledged, it gathers small amounts of output to be sent in a single
    packet once an acknowledgment is received.  For a small number of
    clients, such as window systems that send a stream of mouse events which
    receive no replies, this packetization may cause significant delays.
    Therefore, TCP provides a boolean option, TCP_NODELAY (from
    <netinet/tcp.h>, to defeat this algorithm.  The option level for the set-
    sockopt call is the protocol number for TCP, available from getproto-
    byname (see getprotoent(SLIB)).

    Options at the IP transport level may be used with TCP; see ip(ADMP).
    Incoming connection requests that are source-routed are noted, and the
    reverse source route is used in responding.

    TCP is also available as a TLI connection-oriented protocol via the spe-
    cial file /dev/inet/tcp.  TCP options are supported via the TLI options
    mechanism.

    TCP provides a facility, one-packet mode, that attempts to improve per-
    formance over Ethernet interfaces that cannot handle back-to-back pack-
    ets.  One-packet mode may be set by ifconfig(ADMN) for such an interface.
    On a connection that uses an interface for which one-packet mode has been
    set, TCP attempts to prevent the remote machine from sending back-to-back
    packets by setting the window size for the connection to the maximum seg-
    ment size for the interface.

    Certain TCP implementations have an internal limit on packet size that is
    less than or equal to half the advertised maximum segment size.  When
    connected to such a machine, setting the window size to the maximum seg-
    ment size would still allow the sender to send two packets at a time.  To
    prevent this, a ``small packet size'' and a ``small packet threshold''
    may be specified when setting one-packet mode.  If, on a connection over
    an interface with one-packet mode enabled, TCP receives a number of con-
    secutive packets of the small packet size equal to the small packet
    threshold, the window size is set to the small packet size.

 Diagnostics

    A socket operation may fail with one of the following errors returned:

    [EISCONN]           when trying to establish a connection on a socket
                        which already has one

    [ENOSR]             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 listen-
                        ing 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

 Files

    /dev/inet/tcp

 See also

    getsockopt(SSC), ifconfig(ADMN), inet(ADMP), Intro(ADMP), ip(ADMP), mde-
    vice(F), socket(SSC)


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026