Интерактивная система просмотра системных руководств (man-ов)
tcp (4) ( FreeBSD man: Специальные файлы /dev/* )>> tcp (4) ( Linux man: Специальные файлы /dev/* ) tcp (7) ( Solaris man: Макропакеты и соглашения ) tcp (7) ( Русские man: Макропакеты и соглашения ) tcp (7) ( Linux man: Макропакеты и соглашения )Ключ tcp обнаружен в базе ключевых слов.
tcp - TCP protocol.
tcp_socket = socket(PF_INET, SOCK_STREAM, 0);
This is an implementation of the TCP protocol defined in RFC793, RFC1122
and RFC2001 with the NewReno extensions.
It implements a reliable stream oriented full duplex stream
two sockets. TCP ensures that packets are not reordered and retransmits them
when they are dropped. It generates and checks a per packet checksum to catch
A fresh TCP socket has no remote or local address and is not fully specified.
To create an outgoing TCP connection the
function is called on the socket. To accept incoming connections
the socket first to a local address and port and then call
to allow the accepting of incoming connections. Then use
to get a new socket with the incoming connection. The listening socket
a socket is fully specified.
Data may be only transferred on fully specified sockets.
When the initial connection request packet carries IP options and the
accept_source_routes sysctl is enabled all outgoing datagrams on this
connection will carry the reversed source route.
Linux 2.2 supports the RFC1323 TCP high performance extensions.
They include window scaling to support large windows and the timestamp option with
protection against wrapped sequence numbers (
Large windows are needed for good performance over links with long latencies
or very high bandwidth. To use them the send and receive buffers have to be
increased from the default values. This can be either done globally using the
sysctls, or on a per socket basis using the
socket options. The maximum receive buffer size settable on a socket
is limited by the global
for more information.
TCP supports urgent data. Urgent data is used to signal the receiver
that some important message is part of the data stream and that is should
be processed as soon as possible.
To send urgent data specify the
When urgent data is received the kernel sends an SIGURG signal to the
reading process or the process or process group that has been set for the socket
ioctls. When the
socket option is enabled urgent data is put into the normal data stream
(and can be tested for by the
otherwise it can be only received when the
flag is set for
interpretation of the urgent pointer field, see the
TCP is built on top of IP (see
The address formats defined by
apply to TCP. TCP only supports
point-to-point communication; broadcasting and multicasting are not supported.
These sysctls can be accessed by the
files or with the
interface. In addition, most IP sysctls also apply to TCP; see
Enable RFC1323 TCP window scaling.
Enable RFC2018 TCP Selective Acknowledgements.
Enable RFC1323 TCP timestamps.
How many seconds to wait for a final FIN packet before the socket is forcibly closed.
This is strictly a violation of the TCP specification, but required to prevent
Maximum TCP keep-alive probes to send before giving up. Keep-alives are only
send when the
socket option is enabled.
How often keep-alives are sent on a connection. Defined in seconds. Default
is 2 hours.
How many keep-alive probes are sent per slow timer run. To prevent
bursts, this value should not be set too high.
Enable the strict RFC793 interpretation of the TCP urgent-pointer field.
The default is to use the BSD-compatible interpretation of the urgent-pointer,
pointing to the first byte after the urgent data. The RFC793 interpretation
is to have it point to the last byte of urgent data. Enabling this option
may lead to interoperatibility problems.
Enable TCP syncookies. The kernel must be compiled with
They defend against a particular TCP denial-of-service attack. Note that the
concept of a socket backlog is abandoned; this means the peer may not receive
reliable error messages from an overloaded server with syncookies enabled.
Length of the per-socket backlog queue. As of Linux 2.2, the backlog specified
only specifies the length of the backlog queue of already established sockets.
The maximum queue of sockets not yet established (in
per listen socket is set by this sysctl. When more connection requests arrive,
Linux starts to drop packets. When syncookies, are enabled the packets are still
answered and the maximum queue is effectively ignored.
Defines how many times an answer to a TCP connection request is retransmited before
Defines how many times a TCP packet is retransmitted in established state
before giving up.
Defines how many times to try to send an initial SYN packet to a remote
host before giving up and returns an error. Must be below 255.
This is only the timeout for outgoing connections; for incoming
connections the number of retransmits is defined by
Try to send full-sized packets during retransmit. This is used to work around
TCP bugs in some stacks.
To set or get a TCP socket option, call
to read or
to write the option with the socket family argument set to
socket options are valid on TCP sockets. For more information see
Turn the Nagle algorithm off. This means that packets are always sent as soon
as possible and no unnecessary delays are introduced, at the cost of more
packets in the network. Expects an integer boolean flag.
Set or receive the maximum segment size for outgoing TCP packets. If this
option is set before connection establishment, it also changes the MSS value
announced to the other end in the initial packet. Values greater than
the interface MTU are ignored and have no effect.
If enabled don't send out partial frames.
All queued partial frames are sent when the option is cleared again.
This is useful for prepending headers
or for throughput optimization. This option cannot be combined with
These ioctls can be accessed using
The correct syntax is:
error = ioctl(tcp_socket, ioctl_type, &value);
Returns the amount of queued unread data in the receive buffer. Argument
is a pointer to an integer.
Returns true when the all urgent data has been already received by the user
This is used together with
Argument is an pointer to an integer for the test result.
Returns the amount of unsent data in the socket send queue. Argument is an integer.
When a network error occurs, TCP tries to resend the packet. If it doesn't
succeed after some time, either
or the last received error
on this connection is reported.
Some applications require a quicker error notification.
This can be enabled with the
socket option. When this
option is enabled, all incoming errors are immediately passed to the user program.
Use this option with care - it makes TCP less tolerant to routing changes
and other normal network conditions.
When the other end closes the socket without doing a proper closing handshake, a
signal is raised and EPIPE is returned. This can be prevented by the
The other end closed the socket unexpectedly.
The other end didn't acknowledge retransmitted data after some time.
Passed socket address type in
Any errors defined for
or the generic socket layer may also be returned for TCP.
Not all errors are documented.
IPv6 is not described.
Transparent proxy options are not described.
The sysctls are new in Linux 2.2.
are a new
feature in Linux 2.2.
is new in 2.2.
- ADDRESS FORMATS
- SOCKET OPTIONS
- ERROR HANDLING
- SEE ALSO