ex_udp_init.c

The following example shows how a UDP socket can be created. This socket can be used for

In this example we will always use the remote port value of the remote node that sends us a is not known at the time th

00001 
00011 #include "net\udp.h"
00012 
00013 //Create a UDP socket
00014 static UDP_SOCKET udpSocketUser = INVALID_UDP_SOCKET;
00015 
00016 /*
00017  * UDP Initialization
00018  */
00019 static void udpUserInit(void)
00020 {
00021     NODE_INFO udpServerNode;
00022 
00023     //Initialize remote IP and MAC address of udpServerNode with 0, seeing that we don't
00024     //know them for the node that will send us an UDP message. The first time a message
00025     //is received addressed to this port, the remote IP and MAC addresses are
00026     //automatically updated with the addresses of the remote node.
00027     memclr(&udpServerNode, sizeof(udpServerNode));
00028 
00029     //Configure for local port 54123 and remote port INVALID_UDP_PORT. This opens
00030     //the socket to listed on the given port.
00031     udpSocketUser = UDPOpen(54123, &udpServerNode, INVALID_UDP_PORT);
00032 
00033     //An error occurred during the UDPOpen() function
00034     if (udpSocketUser == INVALID_UDP_SOCKET) {
00035         //Take any additional action that is required when an error occurs
00036         ...
00037     }
00038     else {
00039         //Take any additional action that is required when successfully opened
00040         ...
00041     }
00042 }
00043 
00044 
00045 

Generated on Mon Oct 9 13:22:06 2006 for SBC65EC Web Server by  doxygen 1.4.7