Results 1 to 6 of 6

Thread: [RESOLVED] TCPConnection through router

  1. #1

    Thread Starter
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Resolved [RESOLVED] TCPConnection through router

    Hola all from a new member

    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.
    Last edited by ThomasJohnsen; Jul 18th, 2010 at 04:55 PM.

  2. #2
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: TCPConnection through router

    Welcome to VBF

    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.
    Delete it. They just clutter threads anyway.

  3. #3

    Thread Starter
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Re: TCPConnection through router

    Thank you very much for the help .

    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
    Last edited by ThomasJohnsen; Jul 19th, 2010 at 04:37 AM.

  4. #4
    Member
    Join Date
    Mar 2006
    Posts
    35

    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.

  5. #5
    Member
    Join Date
    Mar 2006
    Posts
    35

    Re: [RESOLVED] TCPConnection through router

    Oh, I also forgot to mention in my case I hard coded my ip address into my server.

  6. #6

    Thread Starter
    Fanatic Member ThomasJohnsen's Avatar
    Join Date
    Jul 2010
    Location
    Denmark
    Posts
    528

    Re: [RESOLVED] TCPConnection through router

    Quote Originally Posted by rudyking View Post
    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.
    In truth, a mature man who uses hair-oil, unless medicinally , that man has probably got a quoggy spot in him somewhere. As a general rule, he can't amount to much in his totality. (Melville: Moby Dick)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width