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. |
ENETRESET |
Socket library is not initialized. |
ENETDOWN |
The network is not available. |
EBADF |
Invalid socket descriptor. |
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