?? tcp.4p
字號:
.\" SCCSID: @(#)tcp.4p 8.1 9/11/90.TH tcp 4p.SH Nametcp \- Internet Transmission Control Protocol.SH Syntax.B #include <sys/socket.h>.br.B #include <netinet/in.h>.PP.B s = socket(AF_INET, SOCK_STREAM, 0);.SH Description.NXR "TCP protocol".NXS "network protocol" "TCP protocol".NXS "Transmission Control Protocol" "TCP protocol"The TCP protocol provides reliable, flow-controlled, two-waytransmission of data. It is a byte-stream protocol used tosupport the SOCK_STREAM abstraction. TCP uses the standardInternet address format and, in addition, provides a per-hostcollection of ``port addresses''. Thus, each address is composedof an Internet address specifying the host and network, witha specific TCP port on the host identifying the peer entity..PPSockets utilizing the TCP protocol are either ``active'' or``passive''. Active sockets initiate connections to passivesockets. By default TCP sockets are created active; to create apassive socket the .MS listen 2 system call must be usedafter binding the socket with the .MS bind 2system call. Only passive sockets can use the .MS accept 2call to accept incoming connections. Only active sockets can use the .MS connect 2call to initiate connections..PPPassive sockets can ``underspecify'' their location to matchincoming connection requests from multiple networks. Thistechnique, termed ``wildcard addressing'', allows a singleserver to provide service to clients on multiple networks..NXR "wildcard addressing" "defined"To create a socket that listens on all networks, the Internetaddress INADDR_ANYmust be bound. The TCP port can still be specifiedat this time. If the port is not specified, the system will assign one.Once a connection has been established, the socket's address isfixed by the peer entity's location. The address assigned thesocket is the address associated with the network interfacethrough which packets are being transmitted and received. Normally,this address corresponds to the peer entity's network..PPTCP supports one socket option that is set with.MS setsockopt 2and tested with.MS getsockopt 2 .Under most circumstances, TCP sends data when it is presented;when outstanding data has not yet been acknowledged, it gatherssmall amounts of output to be sent in a single packet, oncean acknowledgement is received.For a small number of clients, such as window systemsthat send a stream of mouse events that receive no replies,this packetization may cause significant delays.Therefore, TCP provides a Boolean option, TCP_NODELAY (from.PN <netinet/tcp.h> ,to defeat this algorithm.The option level for the.PN setsockoptcall is the protocol number for TCP,available from.MS getprotobyname 3n ..SH DiagnosticsA socket operation may fail with one of the following errors returned:.TP 20[EISCONN]Try to establish a connection on a socket whichalready has one..TP 20[ENOBUFS]The system runs out of memory foran internal data structure..TP 20[ETIMEDOUT]A connection was droppeddue to excessive retransmissions..TP 20[ECONNRESET]The remote peerforces the connection to be closed..TP 20[ECONNREFUSED]The remotepeer actively refuses connection establishment (usually becauseno process is listening to the port)..TP 20[EADDRINUSE]An attemptis made to create a socket with a port that has already beenallocated..TP 20[EADDRNOTAVAIL]An attempt is made to create a socket with a network address for which no network interfaceexists..SH See Alsogetsockopt(2), socket(2), inet(4f), intro(4n), ip(4p)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -