title: Java Socket port forwarding
body: <p>I made a networked game in Java using Sockets. It works great, except... only through my LAN. :/ What I want to be able to do is set it up so that I can start the server running on my home computer and send the client code, in an executable jar, to someone else, and have them be able to launch it and connect through the internet. But like... I have no idea how to set up my modem &amp; router for that. :( I have a wireless Clear modem, for which the configuration page looks like this:</p>
  
  <p><a href="http://imageshack.us/photo/my-images/254/modem.jpg" rel="nofollow">http://imageshack.us/photo/my-images/254/modem.jpg</a></p>
  
  <p>And a Netgear router, whose page looks like this:</p>
  
  <p><a href="http://imageshack.us/photo/my-images/443/routerq.jpg" rel="nofollow">http://imageshack.us/photo/my-images/443/routerq.jpg</a></p>
  
  <p>Right now, in the client and server runner classes, I pass my PC's private IP address along with my chosen port number to the ServerSocket and Socket objects. I hear that Sockets are able to be either UDP or TCP, depending on how you set them up, or something...? I don't do anything like that though, I just instantiate them and pass them the 2 values, and off they go... </p>
  
  <p>In the code for the server:</p>
  
  <pre><code>ServerSocket sock = new ServerSocket();
  sock.bind(new InetSocketAddress(IP, 9001));
  </code></pre>
  
  <p>Code for the client:</p>
  
  <pre><code>Socket sock = new Socket(IP, 9001);
  </code></pre>
  
  <p>So also, I would need to know how to change the code accordingly with the changes to my router/modem settings. </p>
  
  <p>"IP" is a String representing my computer's private IP, 192.168.1.10, and the program only works if that is the string I pass to the Socket &amp; ServerSocket. Like I said, I have a modem which is connected to a router which is connected to my computer. So, can someone please explain to me (in detail, because I'm a noob) what exactly I would have to do to configure both of them, AND the changes I would have to make to my code?</p>