nn::socket::Connect Function
s32 Connect(
s32 s,
const SockAddrIn * sockAddr
);
| Name | Description | |
|---|---|---|
| in | s | Specifies the socket descriptor. Specify a socket descriptor created using the Socket function. |
| in | sockAddr | Specifies a pointer to the socket address structure used to maintain address information about the communication target. |
| Value | Description |
|---|---|
| 0 | Process was successful. |
EAFNOSUPPORT |
The protocol family of the socket does not support the specified address. |
EALREADY |
Already attempting connection in non-blocking mode. |
EBADF |
The socket descriptor is invalid. |
ECONNREFUSED |
The connection was reset just as a socket was opened for communication with the remote host. |
ECONNRESET |
The connection was reset for one of the following reasons: The connection was reset by the remote host to which connection is being attempted. A fatal ICMP notification (such as a Destination Unreachable message) was received while attempting connection. |
EINPROGRESS |
The specified socket is currently changing its status. |
EINVAL |
Indicates an illegal call of one of the following. The socket address specified in sockAddr is invalid. |
EISCONN |
The specified socket cannot be used by this process because it is being used for another purpose (for example, it is already connected). |
ENETDOWN |
The network is not available. |
ENETRESET |
Socket library is not initialized. |
ENETUNREACH |
Could not find the remote host to connect to. |
ENOBUFS |
Failed to temporarily assign a socket address to a socket that has not been assigned a communication source socket address. |
ENOMEM |
Cannot allocate the memory required for the process. |
ETIMEDOUT |
Timed out without receiving a response from the remote host to connect to. |
Uses the specified socket descriptor to attempt to connect to the specified remote host.
If no local address has been bound to the socket using the Bind function, then Connect binds an unused local address to the socket. For a stream socket (SO_SOCK_STREAM), this function usually blocks until a connection is established but it will return as soon as possible if non-blocking mode has been set by the Fcntl function. In such cases, use the Poll function to check whether a connection has been established. If the connection attempt failed, the Poll return value has its POLLRDNORM and POLLWRNORM bits set to 1. You can also detect connection failures via the errors returned by functions that you later call to send or receive data. For a datagram socket (SOCK_DGRAM), this function has the same behavior in both blocking and non-blocking mode because it simply changes the socket address to which datagrams are sent.
CONFIDENTIAL