1 Replies - 3160 Views - Last Post: 30 November 2011 - 04:03 AM Rate Topic: -----

#1 Eqric  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 31-January 11

Simple chat program using socket , canīt connect outside local network

Posted 30 November 2011 - 01:56 AM

Hello, I am making a simple chat program using Sockets.
I tested to put a server on my own computer and tried to connect to it using a client that also lies on my computer, works great!
Then i tried to put the "server" on my friends computer (we are within the same network) then it takes a while and i get the error:
*note: I have tested to forward a port but it still doesnīt work.

Quote

Exception in thread "main" java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at Client.run(Client.java:32)
at Client.main(Client.java:14)

Any idea what i am doing wrong?

Greatfull for all help i can get!

The client
byte [] b = new byte[] { (byte)1x0,(byte)x38,(byte)24x,(byte)x6};
		InetAddress ip = InetAddress.getByAddress(B)/>;
		SocketAddress SA = new InetSocketAddress(ip,443);
	
		
		Socket mySocket = new Socket();
		mySocket.connect(SA,10);
		PrintStream myPS = new PrintStream(mySocket.getOutputStream());
		
		InputStreamReader input = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(input);
		
		
		
		String temp;
		temp = reader.readLine();
		myPS.println(temp); 


Server:
ServerSocket mySS = new ServerSocket(8888);
		Socket SS_accept = mySS.accept();
		
		BufferedReader SS_BF = new BufferedReader(new InputStreamReader(SS_accept.getInputStream()));
		
		
			String temp = SS_BF.readLine();
			System.out.println(temp);


Is This A Good Question/Topic? 0
  • +

Replies To: Simple chat program using socket , canīt connect outside local network

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2776
  • View blog
  • Posts: 11,744
  • Joined: 20-September 08

Re: Simple chat program using socket , canīt connect outside local network

Posted 30 November 2011 - 04:03 AM

Please post the output from the command line of

netstat -an


(assuming Windows) on the server machine
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1