Hi,
I have made a simple server running locally using tcplisten and it works fine over local network e.g. (127.0.0.11:8888).
But how do I now receive connections to the server from the internet, what ip and port do I set??
Thanks
Hi,
I have made a simple server running locally using tcplisten and it works fine over local network e.g. (127.0.0.11:8888).
But how do I now receive connections to the server from the internet, what ip and port do I set??
Thanks
You need to set a firewall rule up on your network to forward any traffic coming into your public IP on that port to be forwarded to the internal IP address of the machine running your server application.
You can still use 8888. Just make sure that your firewall settings permit incoming connections to that port.
Your server will need to run on machine with real-live IP. The server can bind itself to default IP or you can explicitly provide the IP address to bind to. Ports are not a problem as long as no other server application is listening on the same IP:Port.
Assuming this is a windows machine, and assuming that it is a simple network (i.e. that your firewalls are forwarding connections from 8888 to the internal IP, or that the machine has an appropriate externally exposed interface) you should be able to connect via the public interface to your machine. If you are instancing your listener with a particular IP address (127.0.0.1) you may be preventing connections.
You can use IPAddress.Any or save a list of IPs in a configuration and load those from disk.
IPEnpoint e = new IPEndPoint(IPAddress.Any, 8888)
TcpListener l = new TcpListener(e);
You may need to check whether you are behind some kind of NAT box. You can do this by checking your own ip from an internet site like whatismyip and comparing it to the ip of your machine.
You should also change your firewall rules to allow incoming connections.
PS : Web browsers by default connect to port 80. You can connect to different ports by mentioning port in the url like - http://www.example.com:8080/index.html .
There are a few things you need to do:
1) Log in to your Router and set up port forwarding:
2) Add an exception to your firewall to allow TCP traffic from your desired port.
3) Find out the public IP address of your router (try http://www.myipaddress.com) and attempt to connect to your server using that address.
That should be all you need to do.