Change ioctl request parameter to type unsigned long to avoid lint complaints.
[unix-history] / usr / src / lib / libc / sys / connect.2
CommitLineData
5b41da86
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
19914c9b 5.\" @(#)connect.2 6.3 (Berkeley) %G%
5b41da86 6.\"
bf25b211 7.TH CONNECT 2 ""
5b41da86
KM
8.UC 5
9.SH NAME
10connect \- initiate a connection on a socket
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <sys/socket.h>
16.PP
17.ft B
18connect(s, name, namelen)
19int s;
20struct sockaddr *name;
21int namelen;
22.fi
23.SH DESCRIPTION
24The parameter
25.I s
26is a socket.
27If it is of type SOCK_DGRAM,
28then this call permanently specifies the peer to which
29datagrams are to be sent;
30if it is of type SOCK_STREAM,
31then this call attempts to make a connection to
32another socket.
33The other socket is specified by
19914c9b 34.I name,
5b41da86
KM
35which is an address in the communications space of the socket.
36Each communications space interprets the
37.I name
38parameter in its own way.
39.SH "RETURN VALUE
40If the connection or binding succeeds, then 0 is returned.
41Otherwise a \-1 is returned, and a more specific error
42code is stored in \fIerrno\fP.
43.SH "ERRORS
44The call fails if:
45.TP 20
46[EBADF]
47.I S
48is not a valid descriptor.
49.TP 20
50[ENOTSOCK]
51.I S
52is a descriptor for a file, not a socket.
53.TP 20
54[EADDRNOTAVAIL]
55The specified address is not available on this machine.
56.TP 20
57[EAFNOSUPPORT]
58Addresses in the specified address family cannot be used with this socket.
59.TP 20
60[EISCONN]
61The socket is already connected.
62.TP 20
63[ETIMEDOUT]
64Connection establishment timed out without establishing a connection.
65.TP 20
66[ECONNREFUSED]
67The attempt to connect was forcefully rejected.
68.TP 20
69[ENETUNREACH]
70The network isn't reachable from this host.
71.TP 20
72[EADDRINUSE]
73The address is already in use.
74.TP 20
75[EFAULT]
76The \fIname\fP parameter specifies an area outside
77the process address space.
78.TP 20
79[EWOULDBLOCK]
80The socket is non-blocking and the
81and the connection cannot
82be completed immediately.
83It is possible to
84.IR select (2)
85the socket while it is connecting by selecting it for writing.
b5984ffe
KM
86.PP
87.PP
88The following errors are specific to connecting names in the UNIX domain.
89These errors may not apply in future versions of the UNIX ipc domain.
90.TP 15
91[ENOTDIR]
92A component of the path prefix is not a directory.
93.TP 15
94[EINVAL]
95The pathname contains a character with the high-order bit set.
96.TP 15
97[ENAMETOOLONG]
98A component of a pathname exceeded 255 characters,
99or an entire path name exceeded 1023 characters.
100.TP 15
101[ENOENT]
102The named socket does not exist.
103.TP 15
104[EACCES]
105Search permission is denied for a component of the path prefix.
106.TP 15
107[ELOOP]
108Too many symbolic links were encountered in translating the pathname.
5b41da86
KM
109.SH SEE ALSO
110accept(2), select(2), socket(2), getsockname(2)