PDA

View Full Version : QTcpSocket only works local



BrainStorm
3rd August 2010, 18:35
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. :)

squidge
3rd August 2010, 20:27
We can't tell you what you have done wrong until we know what you have done.

Or, in other words, post some code.

BrainStorm
5th August 2010, 01:21
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 (http://doc.qt.nokia.com/4.1/network-fortuneclient.html). Client and server, and it works only localy, as any socket project that i make. :(

tbscope
5th August 2010, 05:41
Can you make connections other than local on that computer?

squidge
5th August 2010, 07:53
I've compiled this example (http://doc.qt.nokia.com/4.1/network-fortuneclient.html). Client and server, and it works only localy, as any socket project that i make. :(

Right, so how is your network configured?

BrainStorm
5th August 2010, 16:19
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?

tbscope
6th August 2010, 05:43
I repeat my question:
Can you actually use internet explorer and go to a website (check it's not in the cache)

squidge
6th August 2010, 07:57
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.

BrainStorm
8th August 2010, 00:04
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 :(

tbscope
8th August 2010, 07:15
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.

squidge
8th August 2010, 11:03
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.

BrainStorm
8th August 2010, 15:24
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 ). :(

BrainStorm
8th August 2010, 15:27
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). :(

squidge
8th August 2010, 17:26
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'

BrainStorm
8th August 2010, 18:28
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'


C:\Users\Alberto>ipconfig/all

Windows IP Configuration

Host Name . . . . . . . . . . . . : Alberto-PC
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : VIA Rhine II Compatible Fast Ethernet Ada
pter
Physical Address. . . . . . . . . : 00-21-97-70-2F-B2
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::a8a0:aa3d:1ee5:341e%11(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
DHCPv6 IAID . . . . . . . . . . . : 234889623
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-13-A4-BF-BC-00-21-97-70-2F-B2

DNS Servers . . . . . . . . . . . : 200.175.182.139
200.175.5.139
NetBIOS over Tcpip. . . . . . . . : Enabled

Tunnel adapter isatap.{4B5533D6-8370-4E1B-8B37-B9A758FF504B}:

Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes

Tunnel adapter Teredo Tunneling Pseudo-Interface:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 2001:0:4137:9e74:1458:d42e:448d:7cad(Pref
erred)
Link-local IPv6 Address . . . . . : fe80::1458:d42e:448d:7cad%13(Preferred)
Default Gateway . . . . . . . . . : ::
NetBIOS over Tcpip. . . . . . . . : Disabled

squidge
8th August 2010, 20:26
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.

BrainStorm
8th August 2010, 21:43
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 :)

squidge
8th August 2010, 22:38
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.

BrainStorm
8th August 2010, 22:43
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 :(

squidge
9th August 2010, 07:55
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.

utkozanenje
4th June 2011, 16:26
sorry for bumping this thread, but I have same problem, my application need to create server where other can connect, but it do it local.. when i give to my friend, he has different internet provider and he can create server

i read this thread, but didn't found the answer what should i do (probably u said it, but i'm not god with network configuration, and couldn't understand..)

i have huawei 520 echolife router, and have all admin priviliges, so what should i enable/disable :)

squidge
4th June 2011, 16:49
That depends on what you have setup, you may need to punch a hole in the firewall and you may need to add a route to your NAT configuration.

We can't tell you exactly what to do because we don't know your exact network configuration.