Results 1 to 4 of 4

Thread: Binding a QTcpSocket to a specific enternet interface

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Binding a QTcpSocket to a specific enternet interface

    Have you tried using QAbstractSocket::setLocalAddress()?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    Banfa (2nd June 2009)

  3. #2
    Join Date
    Jun 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Binding a QTcpSocket to a specific enternet interface

    Hmmmm, I had considered that function but the help says

    Quote Originally Posted by QT Creator Help
    void QAbstractSocket::setLocalAddress ( const QHostAddress & address ) [protected]

    Sets the address on the local side of a connection to address.

    You can call this function in a subclass of QAbstractSocket to change the return value of the localAddress() function after a connection has been established. This feature is commonly used by proxy connections for virtual connection settings.

    Note that this function does not bind the local address of the socket prior to a connection (e.g., QUdpSocket::bind()).

    This function was introduced in Qt 4.1.
    Which suggested to me that this didn't effect the socket binding. I may try giving it a whirl see what happens.

    Like I say once the network architecture is fixed the issue may not be relevant as the routing tables would take care of it all. After posting yesterday I did manage to persuade my colleagues that the planned network architecture wouldn't work.
    Last edited by Banfa; 2nd June 2009 at 10:27.

  4. #3
    Join Date
    Dec 2010
    Posts
    71
    Platforms
    Windows
    Thanks
    26

    Default Re: Binding a QTcpSocket to a specific enternet interface

    I'm having the same problem too. I'm trying to make sure that the tcpsocket uses my wireless connection by setting the setLocalAddress() with my wireless ip and still it sends by the ethernet connection... If i disconnect the ehternet connection it sends on wireless...

    I had to change the function setLocalAddress() in QAbstractSocket.h from protected to public otherwise using QTcpSocket wouldn't let me use the protected function, as it is not declared on QTcpSocket...

    Have you found a solution to this problem?

Similar Threads

  1. Tell QTcpSocket which interface to use
    By rianquinn in forum Qt Programming
    Replies: 7
    Last Post: 23rd December 2010, 17:28
  2. Replies: 4
    Last Post: 2nd September 2007, 19:48

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
  •  
Qt is a trademark of The Qt Company.