AnsweredAssumed Answered

UDP sendto() Broadcast address not working

Question asked by Tim Hutchinson on May 7, 2015
Latest reply on Jul 5, 2015 by Eugene Ryabtsev

Hi All,


     I'm attempting to transmit a small (5 byte) UDP message on the broadcast I.P. address for my local network ( and am not seeing any indication that the message is being sent. If I send the message to a specific address on my network ( it works properly. The sendto() function is returning the proper number of bytes sent, but nobody is receiving. I have Wireshark looking for activity and I have a small utility on a PC that receives UDP messages. Both properly show received data when the UDP broadcast message is sent by another device or if my project transmits to a specific I.P. address,  neither show any activity when a broadcast message is sent by my project. I'm using RTCS 4.0.2 ported to MQX and a Freescale MPC5125 processor. All other Ethernet communications with this project (stream sockets) works properly.




Here's a code snip.


void UDP_CallAll(void)
     uint_32 lSockHandle, lOption;
     int_32 lRetval;
     sockaddr_in addr_send;
     char cTxBuf[] = "Hello";

     //Create a datagram socket
     lSockHandle = socket(AF_INET, SOCK_DGRAM, 0);
     if(lSockHandle == RTCS_SOCKET_ERROR)

     //Bind the socket
     addr_send.sin_family = AF_INET;
     addr_send.sin_port = 1480;
     addr_send.sin_addr.s_addr = INADDR_ANY;
     lRetval = bind(lSockHandle, &addr_send, sizeof(addr_send));
     if(lRetval != RTCS_OK)

     addr_send.sin_family = AF_INET;
     addr_send.sin_port = 1480;
     // addr_send.sin_addr.s_addr = 0x0A000042;  //<-- This works
     addr_send.sin_addr.s_addr = 0x0A0000FF;     //<-- This doesn't (no errors indicated)

     //If RTCS_MSG_NOLOOP flag is set, the datagram is not duplicated for the local host interface
     //If RTCS_MSG_NONBLOCK flag is set, calls to send() or sendto() will be non-blocking and return immediately
     lRetval = sendto(lSockHandle, cTxBuf, 5, lOption, (struct sockaddr *)&addr_send, sizeof(addr_send));
     if(lRetval == RTCS_ERROR)
     else if(lRetval != 5)

     lRetval = shutdown(lSockHandle, FLAG_ABORT_CONNECTION);
     if(lRetval != RTCS_OK)




Any thoughts? Is there a RTCS or MQX option that I need to configure to get this to work? Is UDP Broadcast supported? Maybe I need to Multi-cast? Thanks in advance for any tips, hints or suggestions.



Best Regards,