nn::socket::RecvFrom Function
s32 RecvFrom(
s32 s,
void * buf,
s32 len,
s32 flags,
SockAddrIn * sockFrom
);
| Name | Description | |
|---|---|---|
| in | s | Specifies a socket descriptor. Specifies a socket descriptor created using the Socket or Accept function. |
| in | buf | Specifies a pointer to the buffer used to read out received data. |
| in | len | Specifies the size in bytes of the buffer used to read out received data. |
| in | flags | Specifies the message transmission type. |
| out | sockFrom | Specifies a pointer to the socket address structure used to get the destination's address information. The len field of the socket address must be initialized appropriately (for example, to sizeof(SockAddrIn)). |
| Value | Description |
|---|---|
| 0 | For stream sockets (SOCK_STREAM), this indicates that the socket cannot accept any more messages because the remote host has finished sending messages. For datagram sockets (SOCK_DGRAM), this function does not return 0. |
| 1 | or more: The size (in bytes) of data read. |
EAGAIN |
No data has been received (in the case of non-blocking mode). Already tried to receive data in blocking mode, but it was blocked (in the case of blocking mode). |
EBADF |
The socket descriptor is invalid. |
ECONNRESET |
If the socket is a stream socket (SOCK_STREAM), the connection has been reset for a reason similar to the following. Communication reset by a connected remote host. The connection was canceled for some reason such as an SOCleanup function call or detection of a network interface disconnection. A fatal ICMP notification (such as a Destination Unreachable message) was received while the running process was maintaining the connection. When using a datagram socket (SOCK_DGRAM), an ICMP notification for controlling subsequent communications (a source control message) was received from the destination or a router on the route. |
EINVAL |
Indicates an illegal call of one of the following. The socket address specified in sockFrom is invalid. The pointer specified by buf is invalid. The size specified by len is invalid. This error also results in cases where the call itself may not have been illegal, but an ICMP notification was received indicating the library sent an illegal packet over the network via a datagram socket (SOCK_DGRAM). |
EINTR |
Suspended. |
ENETDOWN |
The network is not available. |
ENETRESET |
Socket library is not initialized. |
ENOMEM |
Cannot allocate the memory required for the process. |
ENOTCONN |
If the specified socket is closed or is a stream socket (SOCK_STREAM), it cannot be used for the process because communications have not been established. If the socket is a datagram socket (SOCK_DGRAM), receiving may have been canceled for some reason such as the source's socket address not being appropriately allocated by Bind or detection of a network interface disconnection. 。 |
EOPNOTSUPP |
An unsupported flag was specified in flags. |
ETIMEDOUT |
If the socket is a stream socket (SOCK_STREAM), receiving was canceled because the connection timed out. If the socket is a datagram socket (SOCK_DGRAM), an ICMP message was received indicating that previously sent data timed out and did not arrive at the destination. |
EWOULDBLOCK |
Same as EAGAIN. |
Attempts to receive data (messages) from a remote host via a socket.
This function usually blocks until the socket receives a message. However, if the Fcntl function has set the socket to non-blocking mode and flags is set to MSG_DONTWAIT, this function does not block and only gets the data already received at the time this function is called.
For datagram sockets (SOCK_DGRAM), the entire message is read out in a single operation. If the message cannot fit into the allocated buffer and MSG_PEEK is not set in flags, any data that does not fit into the buffer is discarded.
For stream sockets (SOCK_STREAM), message boundaries are ignored. In this case, data is returned to the user as it becomes usable.
CONFIDENTIAL