Results 1 to 6 of 6

Thread: UDP Network. receiving pakets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: UDP Network. receiving pakets

    Thanks for your response.
    Is it possible to mix bind() and connectToHost()? As i understood either the one or the other should be used. Where is the bind() missing? i also tryed solutions only with bind() and the writeDatagram() functions. the result was the same: receiving a paket didn't work.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: UDP Network. receiving pakets

    bind() is needed if you want your UDP socket to listen for data.

    connectToHost() is just a convenience for not having to specifiy the receiver when sending packets. I doubt it would conflict with bind().

    "Connect" doesn't have any inherent meaning for UDP, the function is in QUdpSocket because it is in its base class and the developers decided to make it do something useful (allowing to you use write without specifying the receipient) instead of it just doing nothing (or generating an error),

    Cheers,
    _

  3. #3
    Join Date
    Apr 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: UDP Network. receiving pakets

    OK, i think i got this. How can i bind a socket to the port that is used as a source port for transmitting? The transmitter picks its source port randomly, thats fine so far. But how do i tell the socket that it has to listen to that randomly choosen port? It would not be a Problem if the Server response would go to a defined port at client side. But i have to listen to a port that i actually don't know when calling bind().

    Thanks for your help.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: UDP Network. receiving pakets

    Just to be sure: have you checked if binding to a port makes this also the port used for sending?

    If not, you could try connectToHost() and then accessing localPort() for the value to bind()

    Cheers,
    _

Similar Threads

  1. Receiving Streaming frames
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 25th May 2012, 09:14
  2. Receiving reply from page
    By Trok in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2011, 12:31
  3. receiving XButtonEvent but not QMouseEvent
    By vivek.m in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2010, 12:46
  4. mouseMoveEvent receiving zero's
    By JohnTh in forum Newbie
    Replies: 2
    Last Post: 11th September 2009, 17:31
  5. Function not receiving QPixmap
    By nmuntz in forum Qt Programming
    Replies: 14
    Last Post: 3rd February 2009, 00:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.