|
|
1.1 root 1: .\" Copyright (c) 1983 The Regents of the University of California.
2: .\" All rights reserved.
3: .\"
4: .\" Redistribution and use in source and binary forms are permitted provided
5: .\" that: (1) source distributions retain this entire copyright notice and
6: .\" comment, and (2) distributions including binaries display the following
7: .\" acknowledgement: ``This product includes software developed by the
8: .\" University of California, Berkeley and its contributors'' in the
9: .\" documentation or other materials provided with the distribution and in
10: .\" all advertising materials mentioning features or use of this software.
11: .\" Neither the name of the University nor the names of its contributors may
12: .\" be used to endorse or promote products derived from this software without
13: .\" specific prior written permission.
14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17: .\"
18: .\" @(#)tcp.4 6.4 (Berkeley) 6/23/90
19: .\"
20: .TH TCP 4 "June 23, 1990"
21: .UC 5
22: .SH NAME
23: tcp \- Internet Transmission Control Protocol
24: .SH SYNOPSIS
25: .B #include <sys/socket.h>
26: .br
27: .B #include <netinet/in.h>
28: .PP
29: .B s = socket(AF_INET, SOCK_STREAM, 0);
30: .SH DESCRIPTION
31: The TCP protocol provides reliable, flow-controlled, two-way
32: transmission of data. It is a byte-stream protocol used to
33: support the SOCK_STREAM abstraction. TCP uses the standard
34: Internet address format and, in addition, provides a per-host
35: collection of \*(lqport addresses\*(rq. Thus, each address is composed
36: of an Internet address specifying the host and network, with
37: a specific TCP port on the host identifying the peer entity.
38: .PP
39: Sockets utilizing the tcp protocol are either \*(lqactive\*(rq or
40: \*(lqpassive\*(rq. Active sockets initiate connections to passive
41: sockets. By default TCP sockets are created active; to create a
42: passive socket the
43: .IR listen (2)
44: system call must be used
45: after binding the socket with the
46: .IR bind (2)
47: system call. Only
48: passive sockets may use the
49: .IR accept (2)
50: call to accept incoming connections. Only active sockets may
51: use the
52: .IR connect (2)
53: call to initiate connections.
54: .PP
55: Passive sockets may \*(lqunderspecify\*(rq their location to match
56: incoming connection requests from multiple networks. This
57: technique, termed \*(lqwildcard addressing\*(rq, allows a single
58: server to provide service to clients on multiple networks.
59: To create a socket which listens on all networks, the Internet
60: address INADDR_ANY
61: must be bound. The TCP port may still be specified
62: at this time; if the port is not specified the system will assign one.
63: Once a connection has been established the socket's address is
64: fixed by the peer entity's location. The address assigned the
65: socket is the address associated with the network interface
66: through which packets are being transmitted and received. Normally
67: this address corresponds to the peer entity's network.
68: .PP
69: TCP supports one socket option which is set with
70: .IR setsockopt (2)
71: and tested with
72: .IR getsockopt (2).
73: Under most circumstances, TCP sends data when it is presented;
74: when outstanding data has not yet been acknowledged, it gathers
75: small amounts of output to be sent in a single packet once
76: an acknowledgement is received.
77: For a small number of clients, such as window systems
78: that send a stream of mouse events which receive no replies,
79: this packetization may cause significant delays.
80: Therefore, TCP provides a boolean option, TCP_NODELAY (from
81: .IR <netinet/tcp.h> ,
82: to defeat this algorithm.
83: The option level for the
84: .I setsockopt
85: call is the protocol number for TCP,
86: available from
87: .IR getprotobyname (3).
88: .PP
89: Options at the IP transport level may be used with TCP; see
90: .IR ip (4).
91: Incoming connection requests that are source-routed are noted,
92: and the reverse source route is used in responding.
93: .SH DIAGNOSTICS
94: A socket operation may fail with one of the following errors returned:
95: .TP 20
96: [EISCONN]
97: when trying to establish a connection on a socket which
98: already has one;
99: .TP 20
100: [ENOBUFS]
101: when the system runs out of memory for
102: an internal data structure;
103: .TP 20
104: [ETIMEDOUT]
105: when a connection was dropped
106: due to excessive retransmissions;
107: .TP 20
108: [ECONNRESET]
109: when the remote peer
110: forces the connection to be closed;
111: .TP 20
112: [ECONNREFUSED]
113: when the remote
114: peer actively refuses connection establishment (usually because
115: no process is listening to the port);
116: .TP 20
117: [EADDRINUSE]
118: when an attempt
119: is made to create a socket with a port which has already been
120: allocated;
121: .TP 20
122: [EADDRNOTAVAIL]
123: when an attempt is made to create a
124: socket with a network address for which no network interface
125: exists.
126: .SH SEE ALSO
127: getsockopt(2), socket(2), intro(4), inet(4), ip(4)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.