PDA

View Full Version : TCP server-client application with external access



dominate
3rd February 2011, 23:46
Hi,

maybe this is a network question, rather than specific to Qt, but I need to know.
I want to make a TCP server-client connection between two Qt app (one is server, listening, and the other is client, connecting to the IP-port of the server). However, this connection should not only be within a LAN, but also outside of LAN.

For example, from the client, I want to connect to the server with the external IP of the server (not the local IP 192.168. etc, but the real IP) and the port that I choose. If I set my router for port-forwarding, would this be possible? Or in some other way?

Did any one make such directly connection?
Thanks for your help and suggestions.

tbscope
4th February 2011, 05:36
Your computer has a local address inside your local network. For it to be accessible outside this network, you need a router. Forward an incomming port on your router to the desired address and port in your local network.

As always: make sure you are secure.

dominate
4th February 2011, 13:46
Before doing external connection, I even could not make the connection btw Fortune Server - Fortune Client examples. I am running Fortune Server, and then in the same computer Fortune Client, and trying to connect to the IP-port told by Fortune Server, but can not connect*. I have tried to run Fortune Client in another computer in LAN, but the same. I do not know what I am missing.

*When I edit Fortune Server Example code and set IP as localhost (127.0.0.1), yes it is connected within the same computer. However, if I don't edit the code, and let Fortune Server Example find another IP, it finds an IP that I do not recognize, and it can not be connected. I do not know what IP it is finding. I looked ipconfig /all, there is not such IP in anywhere.

dominate
4th February 2011, 20:18
I have tried to connect using external IP from another computer in LAN, but it couldn't. I thought maybe it was because both computers were in the same LAN and so to check it I have installed an application to my Iphone. I have closed the connection of the mobile to carrier, so it was just connected to my LAN. And, SURPRISE!!! From the application in my Iphone, using external IP, I could connect to Qt4 Fortune Server Example and got response!!! So, the problem is not trying to connect using external IP from within the same LAN; because Iphone could connect with another application. So, anyone has idea, why Qt4 Fortune Client Example CAN NOT connect to Fortune Server Example using external IP ?