
SunOS 5.5 Protocols tcp(7P)
NAME tcp, TCP − Internet Transmission Control Protocol
SYNOPSIS #include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_STREAM, 0);
t = t_open("/dev/tcp", O_RDWR);
DESCRIPTION TCP is the virtual circuit protocol of the Internet protocol family. It provides reliable,
flow-controlled, in order, two-way transmission of data. It is a byte-stream protocol lay-
ered above the Internet Protocol (IP), the Internet protocol family’s internetwork
datagram delivery protocol.
Programs can access TCP using the socket interface as a SOCK_STREAM socket type, or
using the Transport Level Interface (TLI) where it supports the connection-oriented
(T_COTS_ORD) service type.
TCP usesIP’s host-level addressing and adds its own per-host collection of “port
addresses.” The endpoints of a TCP connection are identified by the combination of an IP
address and a TCP port number. Although other protocols, such as the User Datagram
Protocol (UDP), may use the same host and port address format, the port space of these
protocols is distinct. See inet(7P) for details on the common aspects of addressing in the
Internet protocol family.
Sockets utilizingTCP are either “active” or “passive”. Active sockets initiate connections
to passive sockets. Both types of sockets must have their local IP address and TCP port
number bound with the bind(3N) system call after the socket is created. By default, TCP
sockets are active. A passive socket is created by calling the listen(3N) system call after
binding the socket with bind(). This establishes a queueingparameter for the passive
socket. After this, connections to the passive socket can be received with the accept(3N)
system call. Active sockets use the connect(3N) call after binding to initiate connections.
By using the special value INADDR_ANY, the local IP address can be left unspecified in
the bind() call by either active or passive TCP sockets. This feature is usually used if the
local address is either unknown or irrelevant. If left unspecified, the localIP address will
be bound at connection time to the address of the network interface used to service the
connection.
Once a connection has been established, data can be exchangedusing the read(2) and
write(2) system calls.
TCP supports one socket option which is set with setsockopt() and tested with
getsockopt(3N). 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 acknowledgementis 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.
modified 3 Jul 1990 7P-341
Comentários a estes Manuais