nn::socket::SendTo Function
s32 SendTo(
s32 s,
const void * buf,
s32 len,
s32 flags,
const SockAddrIn * sockTo
);
| 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 that is used to maintain send data. |
| in | len | Specifies the size of data to be sent in bytes. |
| in | flags | Specifies the message transmission type. |
| in | sockTo | Specifies a pointer to the socket address structure that maintains address information about the destination. This argument is valid only for datagram sockets ( SOCK_DGRAM), but is ignored if the destination's socket address is specified by the Connect function. |
| Value | Description |
|---|---|
0 or higher |
Represents the size of data (in bytes) that has been sent or that is reserved for sending. In non-blocking mode, this is sometimes smaller than the size of data requested. |
EAGAIN |
In blocking mode, indicates that an attempt to send data has already been made and that it is blocked. If the socket is a non-blocking mode stream socket (SOCK_STREAM), data to be sent out-of-band cannot be reserved for sending in the internal send buffer. |
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 cancelled due to disconnection from the access point or some similar cause. 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. |
EINTR |
Suspended. |
EINVAL |
Invalid call. |
EOPNOTSUPP |
An unsupported flag was specified in flags. |
EDESTADDRREQ |
If the socket is a stream socket (SOCK_STREAM), the socket is being used to accept connection requests using the Listen function. If the socket is a datagram socket (SOCK_DGRAM), the socket address of the destination to which data is to be sent is not determined. |
EMSGSIZE |
If the socket is a datagram socket (SOCK_DGRAM), the size of data to be sent exceeds the size of the internal send buffer. |
ENETDOWN |
The network is not available. |
ENETRESET |
Socket library is not initialized. |
ENETUNREACH |
If the socket is a datagram socket (SOCK_DGRAM), an ICMP notification (Destination Unreachable message) was received indicating that the attempted send destination cannot be found or that data previously sent did not arrive at the destination. |
ENOBUFS |
This error indicates that either a socket address cannot be temporarily assigned to a datagram socket (SOCK_DGRAM) for which a source socket address has not been assigned, or that a temporary send buffer (required when sending and receiving data using a single socket) cannot be allocated. |
ENOMEM |
Cannot allocate the memory required for the process. |
ENOTCONN |
Not connected. |
ETIMEDOUT |
If the socket is a stream socket (SOCK_STREAM), sending was cancelled because the connection timed out. If the socket is a datagram socket (SOCK_DGRAM), an ICMP notification (Destination Unreachable message) was received that indicated previously sent data timed out and did not reach the destination. |
EWOULDBLOCK |
Same as EAGAIN. |
Attempts to send data (messages) to a remote host via a socket.
This function normally blocks until there is enough free space in the socket's send buffer to store the messages, unless non-blocking mode has been set by the Fcntl function or MSG_DONTWAIT is set in flags. In those cases this function does not block.
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 flags is not set to MSG_PEEK, 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