UDP Broadcast problem

Discussion in 'C++' started by Mark van Heeswijk, Sep 1, 2003.

  1. Hi all,

    currently i'm working on a client-server application...
    when doing an UDP-broadcast the packet is received ok, at the other side,
    but for some reason after that
    _ANOTHER_ packet is received that has source-address 255.255.255.255, which
    i didn't send.

    This packet generates an error when received :( :
    error 10054 - connection reset by peer

    below is what i use to receive, and the piece of code to set the options:
    ----------------------------------------------------------------------------
    --------------------------------------------
    recvfrom( GlobalSocket, tempBuff, sizeof(tempBuff), (int)NULL, (SOCKADDR
    *)&remote_sockaddr_in,(int *) )
    ----------------------------------------------------------------------------
    --------------------------------------------
    &remote_sockaddr_length);
    //ENABLE BROADCAST
    BOOL fBroadcast = TRUE;
    int err = setsockopt ( GlobalSocket,
    SOL_SOCKET,
    SO_BROADCAST,
    (CHAR *) &fBroadcast,
    sizeof ( BOOL )
    );
    ----------------------------------------------------------------------------
    --------------------------------------------


    Is anybody familiar with this? What could be causing this?

    Thanks in advance,
    Mark
     
    Mark van Heeswijk, Sep 1, 2003
    #1
    1. Advertising

  2. > currently i'm working on a client-server application...
    > when doing an UDP-broadcast the packet is received ok, at the other

    side,
    > but for some reason after that
    > _ANOTHER_ packet is received that has source-address 255.255.255.255,

    which
    > i didn't send.
    >
    > This packet generates an error when received :( :
    > error 10054 - connection reset by peer
    >
    > below is what i use to receive, and the piece of code to set the

    options:
    > ----------------------------------------------------------------------

    ------
    > --------------------------------------------
    > recvfrom( GlobalSocket, tempBuff, sizeof(tempBuff), (int)NULL,

    (SOCKADDR
    > *)&remote_sockaddr_in,(int *) )
    > ----------------------------------------------------------------------

    ------
    > --------------------------------------------
    > &remote_sockaddr_length);
    > file://ENABLE BROADCAST
    > BOOL fBroadcast = TRUE;
    > int err = setsockopt ( GlobalSocket,
    > SOL_SOCKET,
    > SO_BROADCAST,
    > (CHAR *) &fBroadcast,
    > sizeof ( BOOL )
    > );
    > ----------------------------------------------------------------------

    ------
    > --------------------------------------------
    > Is anybody familiar with this? What could be causing this?


    Standard C++ has no support for socket communication, hence your
    question is off-topic here. For suggestions were to post read this
    http://home.wanadoo.nl/efx/c -faq/how-to-post.html#faq-5.9 and this
    http://www.slack.net/~shiva/welcome.txt

    --
    Peter van Merkerk
    peter.van.merkerk(at)dse.nl
     
    Peter van Merkerk, Sep 1, 2003
    #2
    1. Advertising

  3. Oops, sorry...

    Anyway...problem is solved now....seems that the packets where too long :s

    "Peter van Merkerk" <> wrote in message
    news:bivp0l$dp5lc$-berlin.de...
    > > currently i'm working on a client-server application...
    > > when doing an UDP-broadcast the packet is received ok, at the other

    > side,
    > > but for some reason after that
    > > _ANOTHER_ packet is received that has source-address 255.255.255.255,

    > which
    > > i didn't send.
    > >
    > > This packet generates an error when received :( :
    > > error 10054 - connection reset by peer
    > >
    > > below is what i use to receive, and the piece of code to set the

    > options:
    > > ----------------------------------------------------------------------

    > ------
    > > --------------------------------------------
    > > recvfrom( GlobalSocket, tempBuff, sizeof(tempBuff), (int)NULL,

    > (SOCKADDR
    > > *)&remote_sockaddr_in,(int *) )
    > > ----------------------------------------------------------------------

    > ------
    > > --------------------------------------------
    > > &remote_sockaddr_length);
    > > file://ENABLE BROADCAST
    > > BOOL fBroadcast = TRUE;
    > > int err = setsockopt ( GlobalSocket,
    > > SOL_SOCKET,
    > > SO_BROADCAST,
    > > (CHAR *) &fBroadcast,
    > > sizeof ( BOOL )
    > > );
    > > ----------------------------------------------------------------------

    > ------
    > > --------------------------------------------
    > > Is anybody familiar with this? What could be causing this?

    >
    > Standard C++ has no support for socket communication, hence your
    > question is off-topic here. For suggestions were to post read this
    > http://home.wanadoo.nl/efx/c -faq/how-to-post.html#faq-5.9 and this
    > http://www.slack.net/~shiva/welcome.txt
    >
    > --
    > Peter van Merkerk
    > peter.van.merkerk(at)dse.nl
    >
    >
     
    Mark van Heeswijk, Sep 1, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    5,767
  2. Replies:
    0
    Views:
    461
  3. LinuxGuy

    UDP broadcast problem

    LinuxGuy, Jan 24, 2006, in forum: C++
    Replies:
    3
    Views:
    695
    JustBoo
    Jan 24, 2006
  4. Irmen de Jong
    Replies:
    9
    Views:
    801
    Irmen de Jong
    Apr 11, 2007
  5. Grant Edwards

    Problem receiving UDP broadcast packets.

    Grant Edwards, Apr 19, 2011, in forum: Python
    Replies:
    34
    Views:
    3,162
    Grant Edwards
    Apr 21, 2011
Loading...

Share This Page