Results 1 to 4 of 4

Thread: Same port when you pass socketDescriptor?

  1. #1
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Same port when you pass socketDescriptor?

    If you have a QTcpServer and you pass off a new connection to its own thread. Does this also communicate on some random port? Or is it the same port as the listener that this connection is established?

    If it is a different port, how do you deal with firewalls?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Same port when you pass socketDescriptor?

    Quote Originally Posted by Dumbledore View Post
    If you have a QTcpServer and you pass off a new connection to its own thread. Does this also communicate on some random port? Or is it the same port as the listener that this connection is established?
    It's a different port.

    If it is a different port, how do you deal with firewalls?
    You don't. Firewalls should track connections and pass such traffic that was established on another port. At least that's what the TCP protocol says

    If you use iptables, a rule similar to:

    bash Code:
    1. iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    To copy to clipboard, switch view to plain text mode 

    should be present in the firewall for tcp traffic to work properly. If you're not a firewall admin, you needn't care.

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

    Dumbledore (11th December 2007)

  4. #3
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Re: Same port when you pass socketDescriptor?

    Wow, I didn't know that! My firewall is implemented through my router. So I imagine it is designed to follow the TCP specification and I needant worry?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Same port when you pass socketDescriptor?

    Yes, that's correct. Otherwise you wouldn't be able to post on this forum

    BTW. This is completely invisible for all the software - that's the intention of the mechanism. It's even hard to say the socket is related to any "port" - the server just gets another socket and it sort of works (the client still sees it as the port it connected to, but there is another socket listening on that port).

Similar Threads

  1. Replies: 6
    Last Post: 18th April 2007, 15:04

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.