sctp_connectx
() Function
int sctp_connectx(int sd, struct sockaddr *addrs, int addrcnt, sctp_assoc_t *aid);
The sctp_connectx
() requests an SCTP association to be made on a socket. This is similar to connect
(3C) except that an array of peer addresses can be given.
Similar to sctp_bindx
, this function allows a caller to specify multiple addresses at which a peer can be reached. The SCTP stack tries each addresses in the array in a round robin fashion to set up the association. Note that the list of addresses passed in is only used for setting up the association. It does not necessarily equal the set of addresses the peer uses for the resulting association. If the caller wants to find out the set of peer addresses, the caller must use sctp_getpaddrs
to retrieve them after the association has been set up. For more information, see the sctp_bindx
(3C) and sctp_getpaddrs
(3C) man pages.
The following attributes are specified:
-
sd
-
The socket descriptor.
-
addrs
-
If
sd
is an IPv4 socket,addrs
should be an array ofsockaddr_in
structures containing IPv4 addresses. Ifsd
is an IPv6 socket,addrs
should be an array ofsockaddr_in6
structures containing IPv6 or IPv4-mapped IPv6 addresses. -
addrcnt
-
The number of addresses in the array
addrs
. -
aid
-
If the call to
sctp_connectx
() function returns successfully, the association identifier for the newly created association is returned inaid
. This parameter is applicable only to one-to-many SCTP sockets model.
The following error values are defined for sctp_connectx
():
-
EADDRINUSE
-
The address is already in use.
-
EADDRNOTAVAIL
-
No local address is available for this operation.
-
EAFNOSUPPORT
-
Addresses in the specified address family cannot be used with this socket.
-
EALREADY
-
The socket is non-blocking and a previous connection attempt has not yet been completed.
-
EBADF
-
The
sd
parameter is not a valid file descriptor. -
ECONNREFUSED
-
The attempt to connect was forcefully rejected. The calling program should use
connect
to close the socket descriptor, and issue anothersocket
call to obtain a new descriptor before making another attempt. -
EFAULT
-
A parameter can not be accessed.
-
EINTR
-
The connect attempt was interrupted before it is completed. The attempt will be established asynchronously.
-
EINVAL
-
A parameter provided is invalid for this operation.
-
ENOBUFS
-
Insufficient memory is available to complete the operation.
-
EWOULDBLOCK
-
The socket is marked as non-blocking and the requested operation would get blocked.
-
ETIMEDOUT
-
The attempt timed out.
-
EOPNOTSUPP
-
The operation is not supported in this type of socket.