1 .\" $NetBSD: tcp.4,v 1.3 1994/11/30 16:22:35 jtc Exp $
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by the University of
17 .\" California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)tcp.4 8.1 (Berkeley) 6/5/93
41 .Nd Internet Transmission Control Protocol
43 .Fd #include <sys/socket.h>
44 .Fd #include <netinet/in.h>
46 .Fn socket AF_INET SOCK_STREAM 0
50 protocol provides reliable, flow-controlled, two-way
51 transmission of data. It is a byte-stream protocol used to
54 abstraction. TCP uses the standard
55 Internet address format and, in addition, provides a per-host
58 Thus, each address is composed
59 of an Internet address specifying the host and network, with
62 port on the host identifying the peer entity.
64 Sockets utilizing the tcp protocol are either
68 Active sockets initiate connections to passive
71 sockets are created active; to create a
74 system call must be used
75 after binding the socket with the
78 passive sockets may use the
80 call to accept incoming connections. Only active sockets may
83 call to initiate connections.
87 their location to match
88 incoming connection requests from multiple networks. This
90 .Dq wildcard addressing ,
92 server to provide service to clients on multiple networks.
93 To create a socket which listens on all networks, the Internet
98 port may still be specified
99 at this time; if the port is not specified the system will assign one.
100 Once a connection has been established the socket's address is
101 fixed by the peer entity's location. The address assigned the
102 socket is the address associated with the network interface
103 through which packets are being transmitted and received. Normally
104 this address corresponds to the peer entity's network.
107 supports one socket option which is set with
111 Under most circumstances,
113 sends data when it is presented;
114 when outstanding data has not yet been acknowledged, it gathers
115 small amounts of output to be sent in a single packet once
116 an acknowledgement is received.
117 For a small number of clients, such as window systems
118 that send a stream of mouse events which receive no replies,
119 this packetization may cause significant delays.
122 provides a boolean option,
125 .Aq Pa netinet/tcp.h ,
126 to defeat this algorithm.
127 The option level for the
129 call is the protocol number for
132 .Xr getprotobyname 3 .
136 transport level may be used with
140 Incoming connection requests that are source-routed are noted,
141 and the reverse source route is used in responding.
143 A socket operation may fail with one of the following errors returned:
144 .Bl -tag -width [EADDRNOTAVAIL]
146 when trying to establish a connection on a socket which
149 when the system runs out of memory for
150 an internal data structure;
152 when a connection was dropped
153 due to excessive retransmissions;
156 forces the connection to be closed;
157 .It Bq Er ECONNREFUSED
159 peer actively refuses connection establishment (usually because
160 no process is listening to the port);
163 is made to create a socket with a port which has already been
165 .It Bq Er EADDRNOTAVAIL
166 when an attempt is made to create a
167 socket with a network address for which no network interface
179 protocol stack appeared in