| Description | The udp_get_buf function allocates memory for the UDP send buffer into which your application can write the outgoing data packet. The argument size specifies the number of data bytes that the application wants to send. When the UDP frame has been sent, TCPnet automatically de-allocates the memory used by the send buffer. The udp_get_buf function is in the RL-TCPnet library. The prototype is defined in rtl.h. note - Your application must call the udp_get_buf function each time it wants to send a UDP data packet.
- The total size of the allocated memory must not exceed the UDP Maximum Packet Size (1472 bytes).
- Writing more data than the allocated size of the data buffer overwrites the Memory Manager Block links and causes TCPnet to crash.
|
| Example |
#include <rtl.h>
#include <string.h>
void send_data () {
char udp_msg[] = {"Hello World!"};
U8 remip[4] = {192,168,1,100};
U8 *sendbuf;
U16 len;
len = strlen (udp_msg);
sendbuf = udp_get_buf (len);
str_copy (sendbuf, udp_msg);
/* Send 'Hello World!' to remote peer */
udp_send (udp_soc, remip, 1000, sendbuf, len);
}
|