Networking Help

Blitz3D Forums/Blitz3D Programming/Networking Help

superStruct(Posted 2011) [#1]
I'm having a networking problem. I want to create a TCP server at my home, then be able to access it from outside my home network. I'm wondering how to accomplish my task.


PowerPC603(Posted 2011) [#2]
If you want to access your server at home, you'll need to port-forward your server-messages to your computer via your router.

Lets say your WAN-IP is 155.147.21.9 (just an example).
And your computer's LAN-IP is 192.168.0.2. This would be the computer where your server is running on.
For your server, you could use port 7777.

With these values, you can access your router and port-forward any messages sent to your router via port 7777 to your local pc.

How this works, depends on your router.
Look for "Port forward" or "Virtual Server" in your router's interface and configure port 7777 to be redirected to private IP 192.168.0.2 (protocol = both, this means TCP and UDP).

Then, when you want to communicate with your server from the outside, send your TCP messages to IP 155.147.21.9, using port 7777.
Your router will notice this and re-direct your message to LAN-IP 192.168.0.2, using the same port if you like.


Rob the Great(Posted 2011) [#3]
You'll also want to run a quick check to make sure you know what your WAN-IP address is. Unless you're set up to have a static WAN-IP, this will change everytime the lease expires, and also everytime you restart your computer or restart the router.

Also, it's not a bad idea to set your computer to have a static LAN-IP address (192.168.0.2 is a great number to use if it isn't taken). This will ensure that the router doesn't mistakenly send commands to a different IP address than the one your computer is using. If you don't do this step, I doubt it will cause problems because routers usually don't change local IP addresses, but in the rare event that it should happen, this will ensure that the router will always give your computer the IP adress of 192.168.0.2.


PowerPC603(Posted 2011) [#4]
Some routers even don't allow port-forwarding to computers with a dynamic IP-address, so they require a computer with static IP.


superStruct(Posted 2011) [#5]
What would my inbound port be in this case. I have a specified port in my code but my router also wants an inbound port.


PowerPC603(Posted 2011) [#6]
Just use the same port as yur program uses.

Some routers can redirect a message coming from port 7777 to port 8888 for example.

If you set both port values the same, the message is redirected using the same port.