DDraceNetwork Documentation
Loading...
Searching...
No Matches
Network-UDP
Collaboration diagram for Network-UDP:

Functions

NETSOCKET net_udp_create (NETADDR bindaddr)
 
int net_udp_send (NETSOCKET sock, const NETADDR *addr, const void *data, int size)
 
int net_udp_recv (NETSOCKET sock, NETADDR *addr, unsigned char **data)
 
void net_udp_close (NETSOCKET sock)
 

Detailed Description

Function Documentation

◆ net_udp_close()

void net_udp_close ( NETSOCKET  sock)

Closes an UDP socket.

Parameters
sockSocket to close.

◆ net_udp_create()

NETSOCKET net_udp_create ( NETADDR  bindaddr)

Creates a UDP socket and binds it to a port.

Parameters
bindaddrAddress to bind the socket to.
Returns
On success it returns an handle to the socket. On failure it returns nullptr.

◆ net_udp_recv()

int net_udp_recv ( NETSOCKET  sock,
NETADDR addr,
unsigned char **  data 
)

Receives a packet over an UDP socket.

Parameters
sockSocket to use.
addrPointer to an NETADDR that will receive the address.
dataReceived data. Will be invalidated when this function is called again.
Returns
On success it returns the number of bytes received. Returns -1 on error.

◆ net_udp_send()

int net_udp_send ( NETSOCKET  sock,
const NETADDR addr,
const void data,
int  size 
)

Sends a packet over an UDP socket.

Parameters
sockSocket to use.
addrWhere to send the packet.
dataPointer to the packet data to send.
sizeSize of the packet.
Returns
On success it returns the number of bytes sent. Returns -1 on error.