udp_open_mem - opens a UDP socket in a user-supplied memory
int udp_open_mem(struct ipaddr *local, const struct ipaddr *remote, void *mem);
UDP is an unreliable message-based protocol. The size of the message is limited. The protocol has no initial or terminal handshake. A single socket can be used to different destinations.
This function creates a UDP socket in a user-supplied memory. Unless you are hyper-optimizing use udp_open() instead.
IP address passed in local argument will be used to set source IP address in outgoing packets. Also, the socket can be used to receive packets sent to this address. If port in the address is set to zero an ephemeral port will be chosen and filled into the local address.
IP address passed in remote is the default destination for outbound packets. It is used by msend() and mrecv() functions which don't allow for specifying the destination address explicitly. It is also used by udp_send() and udp_sendl() functions if the address parameter of those functions is set to NULL.
The memory passed in mem argument must be at least UDP_SIZE bytes long and can be deallocated only after the socket is closed.
Newly created socket handle. On error, it returns -1 and sets errno to one of the values below.
struct ipaddr addr; int rc = ipaddr_local(&addr, NULL, 5555, 0); char mem[UDP_SIZE]; int s = udp_open_mem(&addr, NULL, mem);