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

#include "net\udp.h"

//Create a UDP socket
static UDP_SOCKET udpSocketUser = INVALID_UDP_SOCKET;

/*
 * UDP Initialization
 */
static void udpUserInit(void)
{
    NODE_INFO udpServerNode;

    //Initialize remote IP and MAC address of udpServerNode with 0, seeing that we don't
    //know them for the node that will send us an UDP message. The first time a message
    //is received addressed to this port, the remote IP and MAC addresses are
    //automatically updated with the addresses of the remote node.
    memclr(&udpServerNode, sizeof(udpServerNode));

    //Configure for local port 54123 and remote port INVALID_UDP_PORT. This opens
    //the socket to listed on the given port.
    udpSocketUser = UDPOpen(54123, &udpServerNode, INVALID_UDP_PORT);

    //An error occurred during the UDPOpen() function
    if (udpSocketUser == INVALID_UDP_SOCKET) {
        //Take any additional action that is required when an error occurs
        ...
    }
    else {
        //Take any additional action that is required when successfully opened
        ...
    }
}




Generated on Wed Feb 3 12:45:33 2010 for SBC65EC Web Server by  doxygen 1.5.8