#include <dolphin/ip.h>
typedef void (* UDPCallback )(UDPInfo* info, s32 result);
typedef struct IPSocket
{
u8 len; // IP_SOCKLEN
u16 family; // IP_INET
u16 port;
u8 addr[IP_ALEN];
} IPSocket;
s32 UDPSend ( UDPInfo* info, const void* data, s32 len,
IPSocket* remote );
s32 UDPSendAsync( UDPInfo* info, const void* data, s32 len,
IPSocket* remote,
UDPCallback callback, s32* result );
UDPSendAsync() transmits a datagram to the target.
The datagram is normally send to the remote
socket unless the remote socket has been specified by
UDPConnect().
When the specified data is transmitted
out from the host, the callback will be
called. Until then, the data should be
kept untouched. A call to UDPSendAsync() does not immediately make
a copy of the data.
If the local socket has not been specified with UDPBind(),
an ephemeral local socket will be automatically chosen between 1024 and 5000.
info |
Pointer to UDPInfo to transmit a datagram. |
data |
The pointer to the data. Any data cache flush or store operation is not necessary. |
len |
The length of the data in bytes. |
remote |
Pointer to the target socket. If the remote socket has been specified by
UDPConnect(), socket specified by
remote will be ignored. |
callback |
Informed when the data has been
transmitted from the host. |
result |
Optional pointer to s32 that receives the function result.
While the operation is in progress, the value *result
is set to IP_ERR_BUSY. |
Note: The specified callback
is not called when the return value of the function is less than zero.
IP_ERR_NONE |
Succeeded. |
IP_ERR_INVALID |
info is not a valid UDPInfo.
Specified remote socket is not valid. |
IP_ERR_BUSY |
Specified socket is busy. |
IP_ERR_UNREACHABLE |
Specified socket is unreachable from this machine. |
IP_ERR_DATASIZE |
The data size exceeds the transfer limit. |
IP_ERR_INS_RESOURCES |
Failed to allocate an ephemeral source port number. |
IP_ERR_SOURCE_QUENCH |
ICMP source quench error. |
IP_ERR_SOCKET_UNSPECIFIED |
Remote socket unspecified. |
IP_ERR_INV_SOCKET |
Specified remote socket address is not valid. |
IP_ERR_NETDOWN |
Local network interface is down. |
Note: The specified callback
is not called when the return value of the function is less than zero.
| zero or greater | Succeeded. The number of transferred bytes. |
IP_ERR_CANCELED |
Operation is canceled with UDPCancel(). |
IP_ERR_CLOSING |
info is closed with
UDPClose(). |