1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
4 .\" Copyright 1989 AT&T
5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH TCP 7P "Jun 30, 2006"
9 .SH NAME
10 tcp, TCP \- Internet Transmission Control Protocol
11 .SH SYNOPSIS
12 .LP
13 .nf
14 \fB#include <sys/socket.h>\fR
15 .fi
16
17 .LP
18 .nf
19 \fB#include <netinet/in.h>\fR
20 .fi
21
22 .LP
23 .nf
24 \fBs = socket(AF_INET, SOCK_STREAM, 0);\fR
25 .fi
26
27 .LP
28 .nf
80 unspecified in the \fBbind()\fR call by either active or passive \fBTCP\fR
81 sockets. This feature is usually used if the local address is either unknown or
82 irrelevant. If left unspecified, the local \fBIP\fR or IPv6 address will be
83 bound at connection time to the address of the network interface used to
84 service the connection.
85 .sp
86 .LP
87 Note that no two TCP sockets can be bound to the same port unless the bound IP
88 addresses are different. IPv4 \fBINADDR_ANY\fR and IPv6 unspecified addresses
89 compare as equal to any IPv4 or IPv6 address. For example, if a socket is bound
90 to \fBINADDR_ANY\fR or unspecified address and port X, no other socket can bind
91 to port X, regardless of the binding address. This special consideration of
92 \fBINADDR_ANY\fR and unspecified address can be changed using the socket option
93 \fBSO_REUSEADDR\fR. If \fBSO_REUSEADDR\fR is set on a socket doing a bind, IPv4
94 \fBINADDR_ANY\fR and IPv6 unspecified address do not compare as equal to any IP
95 address. This means that as long as the two sockets are not both bound to
96 \fBINADDR_ANY\fR/unspecified address or the same IP address, the two sockets
97 can be bound to the same port.
98 .sp
99 .LP
100 If an application does not want to allow another socket using the
101 \fBSO_REUSEADDR\fR option to bind to a port its socket is bound to, the
102 application can set the socket level option \fBSO_EXCLBIND\fR on a socket. The
103 option values of 0 and 1 mean enabling and disabling the option respectively.
104 Once this option is enabled on a socket, no other socket can be bound to the
105 same port.
106 .sp
107 .LP
108 Once a connection has been established, data can be exchanged using the
109 \fBread\fR(2) and \fBwrite\fR(2) system calls.
110 .sp
111 .LP
112 Under most circumstances, \fBTCP\fR sends data when it is presented. When
113 outstanding data has not yet been acknowledged, \fBTCP\fR gathers small amounts
114 of output to be sent in a single packet once an acknowledgement has been
115 received. For a small number of clients, such as window systems that send a
116 stream of mouse events which receive no replies, this packetization may cause
117 significant delays. To circumvent this problem, \fBTCP\fR provides a
118 socket-level boolean option, \fBTCP_NODELAY.\fR \fBTCP_NODELAY\fR is defined in
119 \fB<netinet/tcp.h>\fR, and is set with \fBsetsockopt\fR(3SOCKET) and tested
120 with \fBgetsockopt\fR(3SOCKET). The option level for the \fBsetsockopt()\fR
|
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
4 .\" Copyright 1989 AT&T
5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH TCP 7P "Mar 17, 2014"
9 .SH NAME
10 tcp, TCP \- Internet Transmission Control Protocol
11 .SH SYNOPSIS
12 .LP
13 .nf
14 \fB#include <sys/socket.h>\fR
15 .fi
16
17 .LP
18 .nf
19 \fB#include <netinet/in.h>\fR
20 .fi
21
22 .LP
23 .nf
24 \fBs = socket(AF_INET, SOCK_STREAM, 0);\fR
25 .fi
26
27 .LP
28 .nf
80 unspecified in the \fBbind()\fR call by either active or passive \fBTCP\fR
81 sockets. This feature is usually used if the local address is either unknown or
82 irrelevant. If left unspecified, the local \fBIP\fR or IPv6 address will be
83 bound at connection time to the address of the network interface used to
84 service the connection.
85 .sp
86 .LP
87 Note that no two TCP sockets can be bound to the same port unless the bound IP
88 addresses are different. IPv4 \fBINADDR_ANY\fR and IPv6 unspecified addresses
89 compare as equal to any IPv4 or IPv6 address. For example, if a socket is bound
90 to \fBINADDR_ANY\fR or unspecified address and port X, no other socket can bind
91 to port X, regardless of the binding address. This special consideration of
92 \fBINADDR_ANY\fR and unspecified address can be changed using the socket option
93 \fBSO_REUSEADDR\fR. If \fBSO_REUSEADDR\fR is set on a socket doing a bind, IPv4
94 \fBINADDR_ANY\fR and IPv6 unspecified address do not compare as equal to any IP
95 address. This means that as long as the two sockets are not both bound to
96 \fBINADDR_ANY\fR/unspecified address or the same IP address, the two sockets
97 can be bound to the same port.
98 .sp
99 .LP
100 If an application does not want to allow another socket using the
101 \fBSO_REUSEADDR\fR option to bind to a port its socket is bound to, the
102 application can set the socket level option \fBSO_EXCLBIND\fR on a socket. The
103 option values of 0 and 1 mean enabling and disabling the option respectively.
104 Once this option is enabled on a socket, no other socket can be bound to the
105 same port.
106 .sp
107 .LP
108 Once a connection has been established, data can be exchanged using the
109 \fBread\fR(2) and \fBwrite\fR(2) system calls.
110 .sp
111 .LP
112 Under most circumstances, \fBTCP\fR sends data when it is presented. When
113 outstanding data has not yet been acknowledged, \fBTCP\fR gathers small amounts
114 of output to be sent in a single packet once an acknowledgement has been
115 received. For a small number of clients, such as window systems that send a
116 stream of mouse events which receive no replies, this packetization may cause
117 significant delays. To circumvent this problem, \fBTCP\fR provides a
118 socket-level boolean option, \fBTCP_NODELAY.\fR \fBTCP_NODELAY\fR is defined in
119 \fB<netinet/tcp.h>\fR, and is set with \fBsetsockopt\fR(3SOCKET) and tested
120 with \fBgetsockopt\fR(3SOCKET). The option level for the \fBsetsockopt()\fR
|