Results 1 to 1 of 1

Thread: QUdpSocket bind() - port binding doesn't seem effective

  1. #1
    Join Date
    May 2015
    Posts
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QUdpSocket bind() - port binding doesn't seem effective

    Hi,

    my issue is with QUdpSocket.bind():

    Qt Code:
    1. udpSock = new QUdpSocket(this);
    2. //udpSock->bind(QHostAddress("192.168.221.1"), 41000);
    3. //bool bindResult = udpSock->bind(QHostAddress::AnyIPv4, quint16(41000));
    4. bool bindResult = udpSock->bind();
    5. qDebug() << udpSock->localAddress().toString();
    6. qDebug() << udpSock->localPort();
    7. qDebug() << bindResult;
    8. qDebug() << udpSock->state();
    To copy to clipboard, switch view to plain text mode 

    qDebug output for this code part:
    "0.0.0.0"
    59122
    true
    QAbstractSocket::BoundState

    I send the UDP datagram using QUdpSocket.writeDatagram()
    I am monitoring the packages with Wireshark and the package is sent successfully but the problem is that according to wireshark the source port is never the same as I've configured with bind (and so the receiver sends back an response to a wrong port). It seems randomly configured port because every time I re-run the UDP send the port is different.

    The situation is the same if I use specific IP address and port (commented code part).

    (I've tried this code on Win7 64bit and on Ubuntu 14.04 32bit, but the result is the same.)

    Do I misunderstand something with bind()?


    Added after 15 minutes:


    Problem found:I referred to wrong QUdpSocket object.
    Last edited by susnye; 19th May 2015 at 15:27.

Similar Threads

  1. Replies: 4
    Last Post: 12th November 2014, 20:35
  2. QUdpSocket binding doesn't work
    By bhuff70 in forum Newbie
    Replies: 16
    Last Post: 5th April 2014, 20:56
  3. QUdpSocket connectToHost and bind an the same port
    By aLiEnHeAd in forum Qt Programming
    Replies: 2
    Last Post: 9th September 2010, 07:48
  4. QUdpSocket binding
    By db in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2008, 11:24
  5. QUdpSocket bind / connectToHost ?
    By mnemonic_fx in forum Newbie
    Replies: 2
    Last Post: 17th July 2007, 03:20

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.