1 .\" Copyright (c) 1983, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)connect.2 8.1 (Berkeley) 6/4/93
29 .\" $FreeBSD: src/lib/libc/sys/connect.2,v 1.11.2.8 2003/04/05 16:59:01 ceri Exp $
30 .\" $DragonFly: src/lib/libc/sys/connect.2,v 1.3 2007/07/30 22:11:33 swildner Exp $
37 .Nd initiate a connection on a socket
44 .Fn connect "int s" "const struct sockaddr *name" "socklen_t namelen"
51 this call specifies the peer with which the socket is to be associated;
52 this address is that to which datagrams are to be sent,
53 and the only address from which datagrams are to be received.
54 If the socket is of type
56 this call attempts to make a connection to
58 The other socket is specified by
60 which is an address in the communications space of the socket.
61 Each communications space interprets the
63 parameter in its own way.
64 Generally, stream sockets may successfully
66 only once; datagram sockets may use
68 multiple times to change their association.
69 Datagram sockets may dissolve the association
70 by connecting to an invalid address, such as a null address.
80 is not a valid descriptor.
83 is a descriptor for a file, not a socket.
84 .It Bq Er EADDRNOTAVAIL
85 The specified address is not available on this machine.
86 .It Bq Er EAFNOSUPPORT
87 Addresses in the specified address family cannot be used with this socket.
89 The socket is already connected.
91 Connection establishment timed out without establishing a connection.
92 .It Bq Er ECONNREFUSED
93 The attempt to connect was forcefully rejected.
95 The network is not reachable from this host.
96 .It Bq Er EHOSTUNREACH
97 The remote host is not reachable from this host.
99 The address is already in use.
103 parameter specifies an area outside
104 the process address space.
105 .It Bq Er EINPROGRESS
106 The socket is non-blocking
107 and the connection cannot
108 be completed immediately.
111 for completion by selecting the socket for writing.
113 The socket is non-blocking
114 and a previous connection attempt
115 has not yet been completed.
118 The following errors are specific to connecting names in the
121 These errors may not apply in future versions of the
126 A component of the path prefix is not a directory.
127 .It Bq Er ENAMETOOLONG
128 A component of a pathname exceeded 255 characters,
129 or an entire path name exceeded 1023 characters.
131 The named socket does not exist.
133 Search permission is denied for a component of the path prefix.
135 Write access to the named socket is denied.
137 Too many symbolic links were encountered in translating the pathname.
148 function call appeared in