title: How to use port forwarding on Server?
body: <p>So I'm trying to create a server that works on different wifi networks, and I heard from someone that I need to use port forwarding. Is this something I implement in my code as well as set up on the router? Also how do I set it up on my router? I posted my code below since I don't know if it'll be needed or not.</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());
  IPAddress ipAddr = ipHost.AddressList[1];
  IPEndPoint localEndPoint = new IPEndPoint(ipAddr, port);
  Socket serverSocket = new Socket(ipAddr.AddressFamily,
  SocketType.Stream, ProtocolType.Tcp);
  System.Console.WriteLine("Socket running on port " + port);
  serverSocket.Bind(localEndPoint);
  System.Console.WriteLine("Accepting Connections");
  System.Console.WriteLine(ipAddr);
  
  serverSocket.Listen(10);
  while (true)
  {
      Socket clientSocket = serverSocket.Accept();
      Thread t = new Thread(() =&gt; Login.login(clientSocket));
      System.Console.WriteLine("Client accepted.");
  }
  </code></pre>
  
  <p><strong>Client</strong></p>
  
  <pre><code>System.Console.WriteLine("attempting to connect");
  Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  System.Console.WriteLine("tesinft3");
  clientSocket.Connect(IPAddress.Parse("0.0.0.0"), port);
  System.Console.WriteLine("tesinft4");
  System.Console.WriteLine("Connected to Server");
  </code></pre>