[RESOLVED] TCPConnection through router
Hola all from a new member :wave:
I have written a server/client application using TCP connections. On a LAN it works just fine, since I can supply an IP-address and a port to get from client to server. The problem is that the server program is supposed to be running on a remote machine behind a router, and I can't seem to establish a connection no matter what or how I try.
In short: Computer running server application has IP A and hides behind a router with IP B. I'm using port P. Establishing a TCP connection to A:P isn't possible, due to it being a general IP supplied by the router, and using B:P will not allow me to reach the designated computer. What do I do?
Hopefully this forum can help. Thank you in advance.
Thomas
#EDIT: Forgot to write that I primarily use VB.Net, but any code solving the problem using TCP would help immensely. Converting it will be little effort compared to the hours I've spent on this.
Re: TCPConnection through router
Welcome to VBF :wave:
What you are looking for is Network Address Translation (aka NAT).
It allows you to communicate with the router and set up a forward.
I found an article for implementation in c#
http://pietschsoft.com/post/2009/02/...-via-UPnP.aspx
And a .NET library
http://code.google.com/p/dotnetportmapper/
Reading your using VB.NET I think the latter might be what you are looking for.
Re: TCPConnection through router
Thank you very much for the help :thumb:.
After much frustrated reading tonight, I accidentally stumbled upon a wiki article about NAT myself, and the article helped me lcate some very helpful and interesting (albeit very technical) information. After reading all sorts of complicated approaches (using UPnP which is a further development of Plug&Play for networks to render UDP or TCP access through a router), the most helpful pieces of information was actually found here on this very forum in an old thread :) Using static IP-addresses and port-mapping through the router serves my immidiate purposes - maybe in time I'll further develop the software to a more complicated UPnP solution allowing more flexibility.
Sorry to inconvenience any forum users; had i only known what to look for, it would have been zero problem locating it.
Regards Tom
#EDIT: It works like a charm :). Server and router may even be rebooted and change IP without affecting the software, since I'm using the DNS hostname of the router to establish TCP-connection. Thank you so much for the help TheBigB - couldn't have done it without you and this great forum :)
Re: [RESOLVED] TCPConnection through router
Have you checked out port forwarding?
Like in my case I have a public ip address 11.22.33.44. Port 80 is forwarded to 10.10.10.3.
Re: [RESOLVED] TCPConnection through router
Oh, I also forgot to mention in my case I hard coded my ip address into my server.
Re: [RESOLVED] TCPConnection through router
Quote:
Originally Posted by
rudyking
Have you checked out port forwarding?
Like in my case I have a public ip address 11.22.33.44. Port 80 is forwarded to 10.10.10.3.
That is exactly what I did.
It wasn't neccessary to hard-code the IP though, since the internet provider maintains a DNS address for the router, which allows for a more flexible solution.