How to solve the client/server connection issue behind a router?

I wrote two applications, client and server using Visual C++ 2008. When I try to connect them they work fine in LAN network using local IP address like: 192.168.1.2 for the client and 192.168.1.3 for the server.

The problem is that when they connect over the internet, say for example the client is in a city and the server is in another city and both are behind routers they DO NOT connect even I use the public IP.

 What I know is that the router clients all use one public IP to share internet connection, and the router generate  local IPs for them.
I asked many developers but I had no clear answer, they suggest to disable NAT function of the router or put a redirect port. Then I  responded why MSN for example did not need this kind of configuration to work where multiple users can connect under the same public ip behind a router?

If you know a technique, a website, a resource to solve this problem. Please share it with me I'm waiting...
veepwareAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ericathomeCommented:
When you say client/server, in addition to making sure routers are established on both sides of the router connection (assuming a VPN pair since detail not provided), you need to make sure the ports used by client and server traffic are carried across the router connection. Check the routing tables and the filters on your routers as a beginning to troubleshooting. Do make sure you are using a secure connection such as PPTP in connecting the two routers across the Internet.

See below for some resources on the topic:

DNS Troubleshooting made easy: http://www.experts-exchange.com/articles/Networking/Protocols/DNS/DNS-Troubleshooting-made-easy.html

Building A WCF Router, Part 2: http://msdn.microsoft.com/en-us/magazine/cc546553.aspx

How to Configure a FREE Hardward PPTP VPN Using a DD-WRT Compatible Router: http://www.experts-exchange.com/articles/Software/System_Utilities/Remote_Access/VPN/How-to-Configure-a-FREE-Hardward-PPTP-VPN-Using-a-DD-WRT-Compatible-Router.html

Let me know how it goes and provide additional detail if you need additional ideas. Thanks, Eric
0
Mike_MozhaevCommented:
If you are behind a router it's the router that has your public IP. But your application is not on the router but on a computer behind it. To deal with such situation you'll need to set up port forwarding on your routing.
Simply put port forwarding is the way to specify path from internet to some computer in local network.
E.g. we can redirect all packets coming to port A on router (i.e. your public IP) to port B on 192.168.1.2
Using different external ports we can route traffic to different computers inside LAN.
For more details search for info about NAT (network address translation) and port fowarding.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Is a firewall active and preventing connection ?
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

veepwareAuthor Commented:
Thanks for all of you. But I don't want to touch the router (in other words: NO HARDWARE, but if programmatically then no problem). OK let's go one more time with some extra details.

The clients sends a request (command) to the server, the server however is found on another network.

To clarify things, take the example of  Windows Live Messenger: When I install; it I don't need to touch the router or put any forward port from my part. If I can do it programmatically that it is fine. I attached a diagram on how things are going.

I hope things are clear now,  please feel free to request any extra details to solve this issue.

149mc7l.jpg
0
Mike_MozhaevCommented:
For request-response communication no port forwarding is required since server has address which is visible from outside and routing the response back to client is performed transparently by NAT.
But if you want to use some king of events then your server acts as a client and hence it needs a route to client and this is done by port forwarding.
0
ericathomeCommented:
Do you know the configuration of the two routers? You have to know what is being/not being routed/forwarded between the two routers/firewalls. If no port forwarding is going on, you would not be able to ping internal locations in the other side of the network. Check on the ports you are using to communicate and make sure those ports are open across the routers or you have to evaluate having your client/server conversation talking on different ports.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
veepwareAuthor Commented:
Ericathome, your response help me a lot, Thank you. I accept your answer as a solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.