/* for a working example visit amibehindnat.com */

import javax.swing.JApplet;
import java.awt.Graphics;
import java.net.*;

public class localIP extends JApplet {
	// we do not really need to paint, this is just an example
	public void paint(Graphics g) {	
		// variable for storing the InetAddress
		InetAddress raw_IP;
		
		// host to connect to (same as where the applet is stored)
		String server_HOSTNAME="localhost";

		try {

			// we may have a socket
			raw_IP = new Socket(server_HOSTNAME,80).getLocalAddress();
			
			// redirect the user to an URL
			// raw_IP.getHostAddress() is the local IP
			getAppletContext().showDocument(new URL("http://"+server_HOSTNAME+"/nat.php?l="+raw_IP.getHostAddress()));

		} catch (Exception e) {
			e.printStackTrace();
		}
	} 
}
