1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="TCP/IP Library Reference"
23 HREF="tcpip-library-reference.html"><LINK
26 HREF="net-common-tcpip-manpages-bind.html"><LINK
29 HREF="net-common-tcpip-manpages-getpeername.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="net-common-tcpip-manpages-bind.html"
65 >Chapter 38. TCP/IP Library Reference</TD
71 HREF="net-common-tcpip-manpages-getpeername.html"
85 NAME="NET-COMMON-TCPIP-MANPAGES-CONNECT">connect</H1
94 >CONNECT(2) System Calls Manual CONNECT(2)
97 connect - initiate a connection on a socket
100 #include <sys/types.h>
101 #include <sys/socket.h>
104 connect(int s, const struct sockaddr *name, socklen_t namelen);
107 The parameter s is a socket. If it is of type SOCK_DGRAM, this call
108 specifies the peer with which the socket is to be associated; this
109 address is that to which datagrams are to be sent, and the only address
110 from which datagrams are to be received. If the socket is of type
111 SOCK_STREAM, this call attempts to make a connection to another socket.
112 The other socket is specified by name, which is an address in the commu-
113 nications space of the socket. Each communications space interprets the
114 name parameter in its own way. Generally, stream sockets may success-
115 fully connect() only once; datagram sockets may use connect() multiple
116 times to change their association. Datagram sockets may dissolve the
117 association by connecting to an invalid address, such as a null address.
120 If the connection or binding succeeds, 0 is returned. Otherwise a -1 is
121 returned, and a more specific error code is stored in errno.
124 The connect() call fails if:
126 [EBADF] S is not a valid descriptor.
128 [ENOTSOCK] S is a descriptor for a file, not a socket.
130 [EADDRNOTAVAIL] The specified address is not available on this
133 [EAFNOSUPPORT] Addresses in the specified address family cannot be
134 used with this socket.
136 [EISCONN] The socket is already connected.
138 [ETIMEDOUT] Connection establishment timed out without establish-
141 [EINVAL] A TCP connection with a local broadcast, the all-ones
142 or a multicast address as the peer was attempted.
144 [ECONNREFUSED] The attempt to connect was forcefully rejected.
146 [EINTR] A connect was interrupted before it succeeded by the
147 delivery of a signal.
149 [ENETUNREACH] The network isn't reachable from this host.
151 [EADDRINUSE] The address is already in use.
153 [EFAULT] The name parameter specifies an area outside the pro-
156 [EINPROGRESS] The socket is non-blocking and the connection cannot
157 be completed immediately. It is possible to select(2)
158 or poll(2) for completion by selecting the socket for
159 writing, and also use getsockopt(2) with SO_ERROR to
160 check for error conditions.
162 [EALREADY] The socket is non-blocking and a previous connection
163 attempt has not yet been completed.
165 The following errors are specific to connecting names in the UNIX domain.
166 These errors may not apply in future versions of the UNIX IPC domain.
168 [ENOTDIR] A component of the path prefix is not a directory.
170 [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} charac-
171 ters, or an entire path name exceeded {PATH_MAX} char-
174 [ENOENT] The named socket does not exist.
176 [EACCES] Search permission is denied for a component of the
179 [EACCES] Write access to the named socket is denied.
181 [ELOOP] Too many symbolic links were encountered in translat-
185 accept(2), getsockname(2), getsockopt(2), poll(2), select(2), socket(2)
188 The connect() function call appeared in 4.2BSD.
190 BSD February 15, 1999 BSD
201 SUMMARY="Footer navigation table"
212 HREF="net-common-tcpip-manpages-bind.html"
230 HREF="net-common-tcpip-manpages-getpeername.html"
246 HREF="tcpip-library-reference.html"