#include <cafe.h> #include <cafe/network.h> int SOConnect(int fd, struct sockaddr *addr, int addrlen);
|fd||Descriptor of the socket to connect.|
|addr||Address to which the socket is to be connected.|
|addrlen||Length of the address (in bytes).|
0 upon success. Upon failure, returns
errno is set appropriately.
||Socket library is not initialized.|
||Insufficient memory in the stack.|
||The argument fd does not refer to a socket.|
||Non-supported operation occurred in the stack.|
||Addresses in the specified address family cannot be used with this socket.|
||The socket is already connected.|
||For blocking sockets, indicates that there is already a previous blocked connect call on the same socket.|
||Connection establishment timed out without establishing a connection.|
The attempt to connect was forcefully rejected. The socket must be closed and recreated. Further attempts to connect on this socket will yield
||The network is not reachable from this host.|
||The specified address is not available on this machine.|
||The address is already in use.|
The socket is non-blocking and the connection cannot be completed immediately. It is possible to
||The operation was aborted. When a socket is closed, operations that are blocked on the socket are aborted.|
||Socket resource manager busy processing requests.|
||Requested operation would block.|
||Specified pointer is outside the address space.|
||Internal API error, invalid error code.|
||Internal API error.|
The parameter fd is a socket. If it is of type
SOCK_DGRAM, then this call specifies the peer with which the socket is to be associated; the address to
which datagrams are sent and the only address from which datagrams are received. If it is of type
SOCK_STREAM, then this call attempts to make a connection to another
socket. The other socket is specified by a name, which is an address in the communications space of the socket. Each communications space interprets the name parameter
in its own way.
SOCK_STREAM socket is set to non-blocking, then the socket allows repeated calls to
SOConnect. These calls will return
0 after the socket is
-1 if it is in the process of connecting.
Datagram sockets may use
SOConnect multiple times to change their association. Datagram sockets may also dissolve the association by connecting to an invalid address,
such as a zero address.
SO_ECONNREFUSED, the corresponding socket must be closed and recreated with a call to
SOSocketbefore another connect attempt can be made. Repeated calls to
SOLastErrorto return with
|Callbacks||Do not call this function from any callback function.|
|Interrupt handler||Do not call this function from any interrupt handler.|
|Exception handler||Do not call this function from any exception handler.|
2012/10/09 Updated Errors section.
2012/08/16 Cleanup pass.
2011/07/11 Added Errors section.
2011/02/21 Initial version.