| Example |
#include <rtl.h>
U8 udp_soc;
U16 udp_callback (U8 socket, U8 *remip, U16 remport, U8 *buf, U16 len) {
/* This function is called when UDP data is received */
/* Process received data from 'buf' */
..
return (0);
}
void main (void) {
init ();
/* Initialize the TcpNet */
init_TcpNet ();
udp_soc = udp_get_socket (0, UDP_OPT_SEND_CS | UDP_OPT_CHK_CS, udp_callback);
if (udp_soc != 0) {
/* Open UDP port 1000 for communication */
udp_open (udp_soc, 1000);
}
while (1);
/* Run main TcpNet 'thread' */
main_TcpNet ();
..
}
}
|