|
|
1.1 ! root 1: .TH TCP 4P "7 July 1983" ! 2: .UC 4 ! 3: .SH NAME ! 4: tcp \- Internet Transmission Control Protocol ! 5: .SH SYNOPSIS ! 6: .B #include <sys/socket.h> ! 7: .br ! 8: .B #include <netinet/in.h> ! 9: .PP ! 10: .B s = socket(AF_INET, SOCK_STREAM, 0); ! 11: .SH DESCRIPTION ! 12: The TCP protocol provides reliable, flow-controlled, two-way ! 13: transmission of data. It is a byte-stream protocol used to ! 14: support the SOCK_STREAM abstraction. TCP uses the standard ! 15: Internet address format and, in addition, provides a per-host ! 16: collection of \*(lqport addresses\*(rq. Thus, each address is composed ! 17: of an Internet address specifying the host and network, with ! 18: a specific TCP port on the host identifying the peer entity. ! 19: .PP ! 20: Sockets utilizing the tcp protocol are either \*(lqactive\*(rq or ! 21: \*(lqpassive\*(rq. Active sockets initiate connections to passive ! 22: sockets. By default TCP sockets are created active; to create a ! 23: passive socket the ! 24: .IR listen (2) ! 25: system call must be used ! 26: after binding the socket with the ! 27: .IR bind (2) ! 28: system call. Only ! 29: passive sockets may use the ! 30: .IR accept (2) ! 31: call to accept incoming connections. Only active sockets may ! 32: use the ! 33: .IR connect (2) ! 34: call to initiate connections. ! 35: .PP ! 36: Passive sockets may \*(lqunderspecify\*(rq their location to match ! 37: incoming connection requests from multiple networks. This ! 38: technique, termed \*(lqwildcard addressing\*(rq, allows a single ! 39: server to provide service to clients on multiple networks. ! 40: To create a socket which listens on all networks, the Internet ! 41: address INADDR_ANY ! 42: must be bound. The TCP port may still be specified ! 43: at this time; if the port is not specified the system will assign one. ! 44: Once a connection has been established the socket's address is ! 45: fixed by the peer entity's location. The address assigned the ! 46: socket is the address associated with the network interface ! 47: through which packets are being transmitted and received. Normally ! 48: this address corresponds to the peer entity's network. ! 49: .SH DIAGNOSTICS ! 50: A socket operation may fail with one of the following errors returned: ! 51: .TP 20 ! 52: [EISCONN] ! 53: when trying to establish a connection on a socket which ! 54: already has one; ! 55: .TP 20 ! 56: [ENOBUFS] ! 57: when the system runs out of memory for ! 58: an internal data structure; ! 59: .TP 20 ! 60: [ETIMEDOUT] ! 61: when a connection was dropped ! 62: due to excessive retransmissions; ! 63: .TP 20 ! 64: [ECONNRESET] ! 65: when the remote peer ! 66: forces the connection to be closed; ! 67: .TP 20 ! 68: [ECONNREFUSED] ! 69: when the remote ! 70: peer actively refuses connection establishment (usually because ! 71: no process is listening to the port); ! 72: .TP 20 ! 73: [EADDRINUSE] ! 74: when an attempt ! 75: is made to create a socket with a port which has already been ! 76: allocated; ! 77: .TP 20 ! 78: [EADDRNOTAVAIL] ! 79: when an attempt is made to create a ! 80: socket with a network address for which no network interface ! 81: exists. ! 82: .SH SEE ALSO ! 83: intro(4N), inet(4F) ! 84: .SH BUGS ! 85: It should be possible to send and receive TCP options. ! 86: The system always tries to negotiates the maximum TCP segment ! 87: size to be 1024 bytes. This can result in poor performance ! 88: if an intervening network performs excessive fragmentation.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.