This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil UDP Multicast Send/Receive

Hi,

I am trying to implement UDP Multicast Functionality on Keil MCBSTM32F400 Board.

I have defined a mulicast group ip:port as

 { 224.220.0.1: 1995 }

I want to listen on this group:port combination for any data.

Once data is received, I want to process it and send response back to this same group:port combination.

I am having trouble finding an example of UDP Receive in multicast mode.

Here is what I have done till now.


const uint8_t group_ssdp[NET_ADDR_IP4_LEN] = { UDP_MCAST_SEG1, UDP_MCAST_SEG2, UDP_MCAST_SEG3, UDP_MCAST_SEG4};


static uint32_t UDP_GetScoketCB(int32_t socket, _const  NET_ADDR *addr, const uint8_t *buf,                       uint32_t len)
{
    return (0);
}


void UDP_MCAST_Server(void)
{
int32_t    udp_sock;    /*!< Socket Handle */
netStatus  net_status;  /*!< Socket Functions ReturnCode */
NET_ADDR addr = { NET_ADDR_IP4, PORT_NUM, UDP_MCAST_SEG1, UDP_MCAST_SEG2, UDP_MCAST_SEG3, UDP_MCAST_SEG4 };

// Initialize UDP socket
udp_sock = netUDP_GetSocket (UDP_GetScoketCB);


/* Is it a valid socket? */
if (udp_sock >= 0)
{
    /* 1. Open the port for communication */
    netUDP_Open (udp_sock, PORT_NUM);

    /* 2. Let UDP Multicast datagrams cross a router.  */
    net_status = netUDP_SetOption (udp_sock, netUDP_OptionTTL, 2);

    if (netIGMP_Join (0, group_ssdp) == netOK)
    {
        /* 3. Successfully joined Multicast Group */
        /* How to listen on the above group:port combination ?
           Confused between UDP APIs and BSD APIs.
           Can't find a netUDP_Receive() Function !
        */
         /* 4. Receive Data Here */
         /* 5. Process Data */
         /* 6. Send Response */
    }
    else
    {
        /* 7. Failed to join Multicast Group */
    }
}


Any help will be appreciated.

Thanks in advance!

Parents Reply Children
No data