Search code examples
c#porttcpwan

How to open Ports through C#?


I'm kind of a beginner at programming, so I don't know what I'm about to ask is even possible. I want to make a TCP/IP connection to a server over WAN.

Both Client and Server programs were made by me they work just fine in a LAN. I'm now trying over a WAN. I know the server IP Address and the Port he's listening from, but as a client I can't make the connection. I supposed it's because the Port is not actually open/available.

How can I make this to happen in the server side? Is there a way for me to start the server (maybe as administrator) and for it to open the Port by itself? Is this a router or Firewall issue?

If I wasn't clear enough, feel free to ask.

Cheers.

PS: Let me put it this way: If I make the connection in a LAN, it works. I set it to the local IP Address (192.168....) and choose whatever port I want and it works just fine. Once I put my public IP provided my ISP, it doesn't. I set the firewall router to accept everything and put a new rule in windows firewall to open port 100. What changed?


Solution

  • Please check the following list,

    • Server Firewall rules to exclude the desired port
    • Router Firewall to exclude the desired port
    • Check any installed security software blocking your desired port
    • Last and crucial! Open router interface and configure your NAT settings so the packets running via the desired port are served to your local server IP
    • If everyhting is fine and your ISP is not blocking the desired port then you will have no problem.
    • You can also visit canyouseeme.org in order to check that server listening alright!

    Kind Regards,
    KB