Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I researched on Google about what the use of Port-Forwarding is.
I came to know that the Job of the Port Forwarder is to set a Connection between the Start Computer and End-Computer, which is one of dozens of Local Computers on that Router. For that we must specify on the Router Options, under Port-Forwarding, the mentioned End-Computer which is meant to connect with the Start-Computer.

Now the Port-Forwarding Option is welcome to the Users but its a bit "inconvenient", even more when the Local Computers on the Router often change their Internal IPs. We then have to manually rechange the settings.

My Question is, is there a way to preset the Internal IP of the Local Computer in my VB.NET Code to automatically detect with which Local Computer to connect.
So i do not how, but something like this (LOL): TCPClient.Connect(EXTERNAL IP, INTERNAL IP, PORT)

Is it even possible to preset it on my code, while i know what the Internal and External IP is and also the Port.

So in a line, Bypass Port-Forwarding by Code???
Thanks in advance, Begi
Posted
Updated 25-Oct-12 8:16am
v2

You don't do any of this in your code.

The internal machine that is the target of the port forwarding configuration should be using a static IP address (explicitly entered) OR use DHCP and on the DHCP server, configure it to give out a reserved IP address to that machine every time it asks for one. That way, you don't have to change the port forwarding configuration at all.
 
Share this answer
 
I think you may want to look at the UPNP Protocol[^]

That's the accepted way of devices/PCs on a private LAN negotiating dynamic port forwarding with the router

That's how the Xbox and BitTorrent clients (for example) can all accept incoming connections without you setting anything up on your router
 
Share this answer
 
Comments
[no name] 27-Oct-12 8:38am    
Now i have found a way to automatically add my app to the UPnP list. It is listed there with the start and end port with my computers internal ip, there is also bittorrent listed! Why does bittorrent run correct via UPnP but my app doesnt, when i add to port-forewarding list then it does work? My app uses TCP like bittorrent. Any ideas please help, damn it
Thanks in advance, Begi
barneyman 27-Oct-12 8:47am    
i have no idea - i can't see what you've done :)

Try sniffing the packets to determine where it's going wrong ... MS Network Monitor
[no name] 27-Oct-12 9:10am    
OK thanks for your help, the UPnp option is not that reliable as manually port-forwarding, ill search on this topic, i mark this question as answered

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900