Accepting broadcast UDP datagrams - doesn't work (?!) - VxWorks

This is a discussion on Accepting broadcast UDP datagrams - doesn't work (?!) - VxWorks ; All, SOS:-) I have this chunk of code: struct sockaddr_in tAddr; int fAllowBroadcast = 1; memset( (char *)&tAddr, 0, sizeof( tAddr)); tAddr.sin_family = AF_INET; tAddr.sin_port = PortNo; tAddr.sin_addr.s_addr = InterfaceIP; ListenUdpSocket = socket( AF_INET, SOCK_DGRAM, UDP); if ( ListenUdpSocket { ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Accepting broadcast UDP datagrams - doesn't work (?!)

  1. Accepting broadcast UDP datagrams - doesn't work (?!)

    All, SOS:-)

    I have this chunk of code:
    struct sockaddr_in tAddr;
    int fAllowBroadcast = 1;
    memset( (char *)&tAddr, 0, sizeof( tAddr));
    tAddr.sin_family = AF_INET;
    tAddr.sin_port = PortNo;
    tAddr.sin_addr.s_addr = InterfaceIP;

    ListenUdpSocket = socket( AF_INET, SOCK_DGRAM, UDP);

    if ( ListenUdpSocket < 0 )
    {
    // handle error
    }

    if (setsockopt(ListenUdpSocket, SOL_SOCKET, SO_BROADCAST,
    (void*)&fAllowBroadcast, sizeof(fAllowBroadcast)))
    {
    // handle error
    }

    if (bind( ListenUdpSocket, (struct sockaddr *)&tAddr,
    sizeof( tAddr)))
    {
    // handle error
    }
    ....

    This code runs with no errors, however I don't get any broadcast
    (x.x.x.255) messages when making this recv call:
    MsgLen = recv( ListenUdpSocket,
    &buffer,
    sizeof(buffer),
    0);

    Sniffer says that the broadcast packets are getting through the mac
    layer...

    What am I doing wrong?

    Thanks!

  2. Re: Accepting broadcast UDP datagrams - doesn't work (?!)

    On Jun 10, 5:53 pm, pyast...@gmail.com wrote:
    > All, SOS:-)
    >
    > I have this chunk of code:
    > struct sockaddr_in tAddr;
    > int fAllowBroadcast = 1;
    > memset( (char *)&tAddr, 0, sizeof( tAddr));
    > tAddr.sin_family = AF_INET;
    > tAddr.sin_port = PortNo;
    > tAddr.sin_addr.s_addr = InterfaceIP;
    >
    > ListenUdpSocket = socket( AF_INET, SOCK_DGRAM, UDP);
    >
    > if ( ListenUdpSocket < 0 )
    > {
    > // handle error
    > }
    >
    > if (setsockopt(ListenUdpSocket, SOL_SOCKET, SO_BROADCAST,
    > (void*)&fAllowBroadcast, sizeof(fAllowBroadcast)))
    > {
    > // handle error
    > }
    >
    > if (bind( ListenUdpSocket, (struct sockaddr *)&tAddr,
    > sizeof( tAddr)))
    > {
    > // handle error
    > }
    > ...
    >
    > This code runs with no errors, however I don't get any broadcast
    > (x.x.x.255) messages when making this recv call:
    > MsgLen = recv( ListenUdpSocket,
    > &buffer,
    > sizeof(buffer),
    > 0);
    >
    > Sniffer says that the broadcast packets are getting through the mac
    > layer...
    >
    > What am I doing wrong?
    >
    > Thanks!


    BTW, VxWorks 5.5.1, BCM1125
    Unicast works fine...

+ Reply to Thread