Results 1 to 1 of 1
Thread: Sending Packets to IP
- 10-17-2010, 03:33 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 43
- Rep Power
- 0
Sending Packets to IP
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
after the send button is clickedJava 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 + ")"); }
The connect methodJava 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); } } }
That's all I think it relevant. Let me know if you need more info.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."); } }
Similar Threads
-
not able to receive packets?? pls help.
By abdullahansari in forum New To JavaReplies: 1Last Post: 06-24-2010, 02:19 AM -
path of packets
By priyacvr in forum Java ServletReplies: 1Last Post: 10-30-2009, 08:10 AM -
Reading TCP Packets
By Clive in forum NetworkingReplies: 0Last Post: 07-09-2009, 02:02 PM -
Regarding UDP Datagram packets
By Raghavendra in forum NetworkingReplies: 1Last Post: 06-10-2008, 11:12 PM -
Encrypting packets
By bugger in forum NetworkingReplies: 2Last Post: 02-04-2008, 10:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks