]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/connect.2
This commit was generated by cvs2svn to compensate for changes in r159285,
[FreeBSD/FreeBSD.git] / lib / libc / sys / connect.2
1 .\" Copyright (c) 1983, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)connect.2   8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD$
34 .\"
35 .Dd June 4, 1993
36 .Dt CONNECT 2
37 .Os
38 .Sh NAME
39 .Nm connect
40 .Nd initiate a connection on a socket
41 .Sh LIBRARY
42 .Lb libc
43 .Sh SYNOPSIS
44 .In sys/types.h
45 .In sys/socket.h
46 .Ft int
47 .Fn connect "int s" "const struct sockaddr *name" "socklen_t namelen"
48 .Sh DESCRIPTION
49 The
50 .Fa s
51 argument
52 is a socket.
53 If it is of type
54 .Dv SOCK_DGRAM ,
55 this call specifies the peer with which the socket is to be associated;
56 this address is that to which datagrams are to be sent,
57 and the only address from which datagrams are to be received.
58 If the socket is of type
59 .Dv SOCK_STREAM ,
60 this call attempts to make a connection to
61 another socket.
62 The other socket is specified by
63 .Fa name ,
64 which is an address in the communications space of the socket.
65 Each communications space interprets the
66 .Fa name
67 argument in its own way.
68 Generally, stream sockets may successfully
69 .Fn connect
70 only once; datagram sockets may use
71 .Fn connect
72 multiple times to change their association.
73 Datagram sockets may dissolve the association
74 by connecting to an invalid address, such as a null address.
75 .Sh RETURN VALUES
76 .Rv -std connect
77 .Sh ERRORS
78 The
79 .Fn connect
80 system call fails if:
81 .Bl -tag -width Er
82 .It Bq Er EBADF
83 The
84 .Fa s
85 argument
86 is not a valid descriptor.
87 .It Bq Er ENOTSOCK
88 The
89 .Fa s
90 argument
91 is a descriptor for a file, not a socket.
92 .It Bq Er EADDRNOTAVAIL
93 The specified address is not available on this machine.
94 .It Bq Er EAFNOSUPPORT
95 Addresses in the specified address family cannot be used with this socket.
96 .It Bq Er EISCONN
97 The socket is already connected.
98 .It Bq Er ETIMEDOUT
99 Connection establishment timed out without establishing a connection.
100 .It Bq Er ECONNREFUSED
101 The attempt to connect was forcefully rejected.
102 .It Bq Er ENETUNREACH
103 The network is not reachable from this host.
104 .It Bq Er EHOSTUNREACH
105 The remote host is not reachable from this host.
106 .It Bq Er EADDRINUSE
107 The address is already in use.
108 .It Bq Er EFAULT
109 The
110 .Fa name
111 argument specifies an area outside
112 the process address space.
113 .It Bq Er EINPROGRESS
114 The socket is non-blocking
115 and the connection cannot
116 be completed immediately.
117 It is possible to
118 .Xr select 2
119 for completion by selecting the socket for writing.
120 .It Bq Er EINTR
121 The connection attempt was interrupted by the delivery of a signal.
122 The connection will be established in the background,
123 as in the case of
124 .Er EINPROGRESS .
125 .It Bq Er EALREADY
126 A previous connection attempt has not yet been completed.
127 .It Bq Er EACCES
128 An attempt is made to connect to a broadcast address (obtained through the
129 .Dv INADDR_BROADCAST
130 constant or the
131 .Dv INADDR_NONE
132 return value) through a socket that does not provide broadcast functionality.
133 .El
134 .Pp
135 The following errors are specific to connecting names in the UNIX domain.
136 These errors may not apply in future versions of the UNIX IPC domain.
137 .Bl -tag -width Er
138 .It Bq Er ENOTDIR
139 A component of the path prefix is not a directory.
140 .It Bq Er ENAMETOOLONG
141 A component of a pathname exceeded 255 characters,
142 or an entire path name exceeded 1023 characters.
143 .It Bq Er ENOENT
144 The named socket does not exist.
145 .It Bq Er EACCES
146 Search permission is denied for a component of the path prefix.
147 .It Bq Er EACCES
148 Write access to the named socket is denied.
149 .It Bq Er ELOOP
150 Too many symbolic links were encountered in translating the pathname.
151 .El
152 .Sh SEE ALSO
153 .Xr accept 2 ,
154 .Xr getpeername 2 ,
155 .Xr getsockname 2 ,
156 .Xr select 2 ,
157 .Xr socket 2
158 .Sh HISTORY
159 The
160 .Fn connect
161 system call appeared in
162 .Bx 4.2 .