Imported Upstream version 1.0.10
[platform/upstream/lksctp-tools.git] / man / sctp_connectx.3
1 .\" (C) Copyright Frank Filz IBM Corp. 2005.
2 .\"
3 .\" Permission is granted to distribute possibly modified copies
4 .\" of this manual provided the header is included verbatim,
5 .\" and in case of nontrivial modification author and date
6 .\" of the modification is added to the header.
7 .\"
8 .TH SCTP_CONNECTX 3 2005-10-25 "Linux 2.6" "Linux Programmer's Manual"
9 .SH NAME
10 sctp_connectx \- initiate a connection on an SCTP socket using multiple
11 destination addresses.
12 .SH SYNOPSIS
13 .nf
14 .B #include <sys/types.h>
15 .B #include <sys/socket.h>
16 .B #include <netinet/sctp.h>
17 .sp
18 .BI "int sctp_connectx(int " sd ", struct sockaddr * " addrs ", int " addrcnt,
19 .BI "                  sctp_assoc_t  * "id );
20 .fi
21 .SH DESCRIPTION
22 .BR sctp_connectx
23 initiates a connection to a set of addresses passed in the array
24 .I addrs
25 to/from the socket
26 .I sd.
27 .I addrcnt
28 is the number of addresses in the array.
29 .PP
30 If
31 .I sd
32 is an IPv4 socket, the addresses passed must be IPv4 addresses. If
33 .I sd
34 is an IPv6 socket, the addresses passed can be either IPv4 or IPv6
35 addresses.
36 .PP
37 .I addrs
38 is a pointer to an array of one or more socket addresses. Each address is
39 contained in its appropriate structure(i.e. struct sockaddr_in or struct
40 sockaddr_in6). The family of the address type must be used to distinguish
41 the address length. The caller specifies the number of addresses in the
42 array with
43 .I addrcnt. 
44 .PP
45 .I id
46 is a pointer to the association id and, if provided, will be set to the
47 identifier of the newly created association.
48 .SH "RETURN VALUE"
49 On success, 0 is returned. On failure, \-1 is returned, and
50 .I errno
51 is set appropriately.
52 .SH ERRORS
53 .TP
54 .B EBADF
55 .I sd
56 is not a valid descriptor.
57 .TP
58 .B ENOTSOCK
59 .I sd
60 is a descriptor for a file, not a socket.
61 .TP
62 .B EFAULT
63 Error while copying in or out from the user address space.
64 .TP
65 .B EINVAL
66 Invalid port or address.
67 .TP
68 .B EACCES
69 The address is protected, and the user is not the super-user.
70 .TP
71 .B EISCONN
72 The socket is already connected.
73 .TP
74 .B ECONNREFUSED
75 No one listening on the remote address.
76 .TP
77 .B ETIMEDOUT
78 Timeout while attempting connection. The server may be too 
79 busy to accept new connections. Note that for IP sockets the timeout may
80 be very long when syncookies are enabled on the server.
81 .TP
82 .B ENETUNREACH
83 Network is unreachable.
84 .TP
85 .B EADDRINUSE
86 Local address is already in use.
87 .TP
88 .B EINPROGRESS
89 The socket is non-blocking and the connection cannot be completed
90 immediately.  It is possible to
91 .BR select (2)
92 or 
93 .BR poll (2) 
94 for completion by selecting the socket for writing. After 
95 .B select
96 indicates writability, use
97 .BR getsockopt (2)
98 to read the 
99 .B SO_ERROR
100 option at level 
101 .B SOL_SOCKET
102 to determine whether 
103 .B connect
104 completed successfully 
105 .RB ( SO_ERROR
106 is zero) or unsuccessfully 
107 .RB ( SO_ERROR
108 is one of the usual error codes listed here, 
109 explaining the reason for the failure).
110 .TP
111 .B EALREADY
112 The socket is non-blocking and a previous connection attempt has not yet
113 been completed.
114 .TP
115 .B EAGAIN
116 No more free local ports or insufficient entries in the routing cache. For
117 .B PF_INET
118 see the 
119 .B net.ipv4.ip_local_port_range
120 sysctl in 
121 .BR ip (7) 
122 on how to increase the number of local ports.
123 .TP
124 .B EAFNOSUPPORT
125 The passed address didn't have the correct address family in its 
126 .I sa_family
127 field.
128 .TP
129 .B EACCES, EPERM
130 The user tried to connect to a broadcast address without having the socket 
131 broadcast flag enabled or the connection request failed because of a local
132 firewall rule.
133 .SH "SEE ALSO"
134 .BR sctp (7)
135 .BR sctp_bindx (3),
136 .BR sctp_sendmsg (3),
137 .BR sctp_send (3),
138 .BR sctp_recvmsg (3),
139 .BR sctp_peeloff (3),
140 .BR sctp_getpaddrs (3),
141 .BR sctp_getladdrs (3),
142 .BR sctp_opt_info (3),