I'm making an instant messenger program to test sending packets. I've got it so I can run the instant messenger program with any computer on my network using their network IP but when I went to try it with internet IP with someone in canada I learned that it will not connect. In this screenshot you can see the program connects fine on the left but does not connect at all on the right (the internet ip). The port is open on both computers and the program is running while I try and send the packets so the sockets are setup aswel. Packets would be pretty useless if you couldn't send them over the internet so I must be doing something wrong. I'm not sure what information you would need to see so I'll post whatever I think it relevant.



in the main method

Java Code:
	   
				port = 1337;
		connectingPort = 1337;
		IP = "192.168.2.6";  //Can be changed before first message is sent
			
				.....removed some lines

				try
		{
			mySocket = new ServerSocket(port);
			MR = new MessageReciever(mySocket);
			append("Connected to port: " + port);
		}
		catch(IOException e)
		{
			append("Cannot connect to this port (" + port + ")");
		}
after the send button is clicked

Java Code:
		public void actionPerformed(ActionEvent e)
	{
		if(e.getActionCommand().equals("Send Message"))
		{
			if(!connected)
			{
				IP = IPAddress.getText();
				connect();
			}

			if(connected)
			{
				name = OutgoingName.getText();
				outgoingMessage = name + ": " + SendMessage.getText();
				SendMessage.setText("");
				append(outgoingMessage);
				out.println(outgoingMessage);
			}
		}
	}
The connect method

Java Code:
		public void connect()
	{
		append("Connecting to: " + IP + " (port: " + connectingPort + ")...");

		try
		{
			toSocket = new Socket(IP, connectingPort);
			out = new PrintWriter(toSocket.getOutputStream(), true);

			append("\tConnected to user.");
			append("==============================================\n");
			connected = true;
		}
		catch(IOException e)
		{
			append("\tCannot connect to this user.");
		}
	}
That's all I think it relevant. Let me know if you need more info.