Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: QTcpSocket only works local

  1. #1
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTcpSocket only works local

    Sorry my english, it's horrible i know, but i really need a light.
    I've started to learn Qt a few weeks ago and I'm now on a chat project, since a few days now and, i realized that, unfortunately, my sockets connections only works local, and that's really sad, i've done too much (for a newbie) now, and I really want to learn how to make it works externally.
    It's too much code to paste here but, i'm following strictly the examples on oficial reference (fortune client and all), and even the pure example just works local when i reproduce it.
    Thanks in advance, i hope you guys understand my english and help me as soon as possible.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    We can't tell you what you have done wrong until we know what you have done.

    Or, in other words, post some code.

  3. #3
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    We can't tell you what you have done wrong until we know what you have done.

    Or, in other words, post some code.

    I've compiled this example. Client and server, and it works only localy, as any socket project that i make.
    Last edited by BrainStorm; 5th August 2010 at 01:22. Reason: spelling corrections

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QTcpSocket only works local

    Can you make connections other than local on that computer?

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by BrainStorm View Post
    I've compiled this example. Client and server, and it works only localy, as any socket project that i make.
    Right, so how is your network configured?

  6. #6
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    Right, so how is your network configured?
    Computer>modem>line
    I use windows 7, firewall turned off now, but nothing, qt socket apps can't make connections but local
    did anybody had the same problem?
    Last edited by BrainStorm; 5th August 2010 at 16:23. Reason: spelling corrections

  7. #7
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QTcpSocket only works local

    I repeat my question:
    Can you actually use internet explorer and go to a website (check it's not in the cache)

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by BrainStorm View Post
    Computer>modem>line
    I use windows 7, firewall turned off now, but nothing, qt socket apps can't make connections but local
    did anybody had the same problem?
    So you only have 1 pc in the house and it's connected to the modem? If so, it sounds like your modem is blocking incoming connections. Might want to check it's configuration.

  9. #9
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    So you only have 1 pc in the house and it's connected to the modem? If so, it sounds like your modem is blocking incoming connections. Might want to check it's configuration.
    so why any other problem have network problems? everythings work fine... jesus christ, i've search all around the internet, and nobody seems to be able to help me, nobody seems to want to share simple information like this
    Last edited by BrainStorm; 8th August 2010 at 00:09.

  10. #10
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QTcpSocket only works local

    Ok, lets try for the third and LAST time:

    On this computer where you have problems connecting to anything but local:
    Can you open a web browser and go to any website?

    If you can't answer this simple question for me, I can't know if the problem is in the Qt library or your computer/network connection. This is called a process of elimination.

  11. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by BrainStorm View Post
    so why any other problem have network problems? everythings work fine...
    So you can make outgoing connections (eg. web browser) and receive incoming connections absolutely fine?

    Is your network NAT'd? If so, perhaps other programs configure UPNP transparently for you and we are back to modem configuration.

  12. #12
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by tbscope View Post
    Ok, lets try for the third and LAST time:

    On this computer where you have problems connecting to anything but local:
    Can you open a web browser and go to any website?

    If you can't answer this simple question for me, I can't know if the problem is in the Qt library or your computer/network connection. This is called a process of elimination.
    Sorry, my english must be confusing but, i said "everythings work fine", i have never had any connection problem, with browsers nor p2p programs, everythings works fine, but my socket projects, or better saying, the socket examples from Qt Creator ( same from reference ).

  13. #13
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    So you can make outgoing connections (eg. web browser) and receive incoming connections absolutely fine?

    Is your network NAT'd? If so, perhaps other programs configure UPNP transparently for you and we are back to modem configuration.
    Yes, ingoing connections too I think, because p2p, download managers, messengers and everything else works very fine...
    There's something that should help anyone that understands these stuff, if I change the local IP (127.0.0.1) to my external one, it doesn't connect either, EVEN when both server and client are running in my computer (local).

  14. #14
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    Start->Run type "cmd" and press enter.
    After the window opens, type "ipconfig"
    There is some number after "Ethernet adapter LAN: IP Address". Paste it.

    I do NOT want your external IP address, just the IP address of your PC.
    If you don't want to paste the whole address, just paste the first number before the first '.', so 1.2.3.4 would be '1'

  15. #15
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    Start->Run type "cmd" and press enter.
    After the window opens, type "ipconfig"
    There is some number after "Ethernet adapter LAN: IP Address". Paste it.

    I do NOT want your external IP address, just the IP address of your PC.
    If you don't want to paste the whole address, just paste the first number before the first '.', so 1.2.3.4 would be '1'
    Qt Code:
    1. C:\Users\Alberto>ipconfig/all
    2.  
    3. Windows IP Configuration
    4.  
    5. Host Name . . . . . . . . . . . . : Alberto-PC
    6. Primary Dns Suffix . . . . . . . :
    7. Node Type . . . . . . . . . . . . : Hybrid
    8. IP Routing Enabled. . . . . . . . : No
    9. WINS Proxy Enabled. . . . . . . . : No
    10.  
    11. Ethernet adapter Local Area Connection:
    12.  
    13. Connection-specific DNS Suffix . :
    14. Description . . . . . . . . . . . : VIA Rhine II Compatible Fast Ethernet Ada
    15. pter
    16. Physical Address. . . . . . . . . : 00-21-97-70-2F-B2
    17. DHCP Enabled. . . . . . . . . . . : No
    18. Autoconfiguration Enabled . . . . : Yes
    19. Link-local IPv6 Address . . . . . : fe80::a8a0:aa3d:1ee5:341e%11(Preferred)
    20. IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred)
    21. Subnet Mask . . . . . . . . . . . : 255.255.255.0
    22. Default Gateway . . . . . . . . . : 192.168.1.1
    23. DHCPv6 IAID . . . . . . . . . . . : 234889623
    24. DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-13-A4-BF-BC-00-21-97-70-2F-B2
    25.  
    26. DNS Servers . . . . . . . . . . . : 200.175.182.139
    27. 200.175.5.139
    28. NetBIOS over Tcpip. . . . . . . . : Enabled
    29.  
    30. Tunnel adapter isatap.{4B5533D6-8370-4E1B-8B37-B9A758FF504B}:
    31.  
    32. Media State . . . . . . . . . . . : Media disconnected
    33. Connection-specific DNS Suffix . :
    34. Description . . . . . . . . . . . : Microsoft ISATAP Adapter
    35. Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
    36. DHCP Enabled. . . . . . . . . . . : No
    37. Autoconfiguration Enabled . . . . : Yes
    38.  
    39. Tunnel adapter Teredo Tunneling Pseudo-Interface:
    40.  
    41. Connection-specific DNS Suffix . :
    42. Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
    43. Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
    44. DHCP Enabled. . . . . . . . . . . : No
    45. Autoconfiguration Enabled . . . . : Yes
    46. IPv6 Address. . . . . . . . . . . : 2001:0:4137:9e74:1458:d42e:448d:7cad(Pref
    47. erred)
    48. Link-local IPv6 Address . . . . . : fe80::1458:d42e:448d:7cad%13(Preferred)
    49. Default Gateway . . . . . . . . . : ::
    50. NetBIOS over Tcpip. . . . . . . . : Disabled
    To copy to clipboard, switch view to plain text mode 

  16. #16
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    Right, so do you have the ports used by fortune server forwarded by your router? If not, you are not going to be able to do anything but local traffic.

  17. #17
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    Right, so do you have the ports used by fortune server forwarded by your router? If not, you are not going to be able to do anything but local traffic.
    hmmmmm, i feeling we're getting close, i'm actually using an once unnused port, 2112, first, how do I know the fowarded ports of my router, and second, how do i foward one?
    And if everthings works fine, looks like HTTP, FTP, P2P, SSH and Messengers ports are all fowarded?
    thanks in advance fatjuicymole
    Last edited by BrainStorm; 8th August 2010 at 23:31. Reason: updated contents

  18. #18
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    HTTP/FTP/SSH are outbound only. They don't need to be forwarded. Your PC requests the connection. P2P can detect your PC is unreachable and since you connect to lots of other people, rather than people connecting to you, it can inform your PC via a proxy to connect to them. Same with Messenger, which connects to a central hub to relay messages.

    I don't know your router, and so I've no idea how it works. Did you buy it or did it come free from your ISP? The former should be easy to edit the configuration. The later is normally more difficult as ISPs like to lock these things down to stop people from messing with it.

    Either way, you may want to lookup the UPnP architecture. Maybe your router has it enabled. If it is, your P2P/Messenger client is most likely already using it to forward ports to itself.

  19. #19
    Join Date
    Aug 2010
    Posts
    26
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpSocket only works local

    Quote Originally Posted by fatjuicymole View Post
    HTTP/FTP/SSH are outbound only. They don't need to be forwarded. Your PC requests the connection. P2P can detect your PC is unreachable and since you connect to lots of other people, rather than people connecting to you, it can inform your PC via a proxy to connect to them. Same with Messenger, which connects to a central hub to relay messages.

    I don't know your router, and so I've no idea how it works. Did you buy it or did it come free from your ISP? The former should be easy to edit the configuration. The later is normally more difficult as ISPs like to lock these things down to stop people from messing with it.

    Either way, you may want to lookup the UPnP architecture. Maybe your router has it enabled. If it is, your P2P/Messenger client is most likely already using it to forward ports to itself.
    My modem is a SmartAX MT880a, my ISP provided it but i have full access to it, but, i'm not going to mess with it so, i have to learn how to (in code) use upnp to forward ports and make my apps works fine, can you point me a start? thanks anyway, you're being a light.

    update:
    I was looking aroung my modem configuration and, upnp is not active, but firewall is. I've gone further, I've runned remote nmap agains me and the results looks weird, like i'm not even up (no ping). I'm afraid of turning off my modem's firewall, what a sad problem
    Last edited by BrainStorm; 8th August 2010 at 23:31.

  20. #20
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpSocket only works local

    Yes, your modem has your external IP address, so no one even knows your PC exists as the modem will typically block all pings. This is a great advantage - any attacks get aimed at your modem rather than your PC so far less risk of your PC being hacked, as people can't see it.

    No need to turn off the firewall, just enable the upnp and leave it as that. Make sure you use Windows update as the original version of UPNP on Windows had some vulnerabilities.

    How to use UPNP in Qt is really beyond the scope of this forum, but there is a lot of information out there and a good number of open source apps which have UPNP included.

Similar Threads

  1. Local Status Bar Does Not Update
    By shawno in forum Qt Programming
    Replies: 0
    Last Post: 16th July 2010, 01:34
  2. item local coordinate
    By dreamer in forum Qt Programming
    Replies: 6
    Last Post: 11th May 2008, 22:49
  3. How to get and set local ip in windows xp using QT?
    By longtrue in forum Qt Programming
    Replies: 0
    Last Post: 5th May 2008, 08:55
  4. Replies: 1
    Last Post: 24th September 2007, 09:02
  5. How to get local IP
    By naresh in forum Qt Programming
    Replies: 11
    Last Post: 17th May 2006, 15: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.