Java Beginners

Moderators: zibadian
Number of threads: 1233
Number of posts: 2675

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Connection reset problem Posted by Kassam on 11 Sept 2007 at 8:39 PM
Hi, I wrote a class that should set up a server on my computer, and another class, a client, that should connect to it, here is the code of the two classes :
Server Class
public class Server
{
	public static void main(String args[]) throws Exception
	{
		ServerSocket ss=new ServerSocket(3311);	
		Socket s=ss.accept();
		System.out.println("Connection Established...");
		InputStream is=s.getInputStream();
		InputStreamReader isr=new InputStreamReader(is);
		BufferedReader br=new BufferedReader(isr);
		String input;

			input=br.readLine();
			System.out.println(input);		
	}
}


Client Class
public class clienting
{
	public static void main(String args[]) throws Exception
	{
		Socket s=new Socket("192.218.218.109",3311); //My external IP address
		System.out.println("Connection Established");
		OutputStream os=s.getOutputStream();
		OutputStreamWriter osw=new OutputStreamWriter(os);
		BufferedWriter bw=new BufferedWriter(osw);
		PrintWriter pw=new PrintWriter(bw);
		
			pw.println("hello");
			pw.flush();
		


	}
}


I run the server, then I run the client, a connection is established, and "hello" should appear on the server's console, instead, it gives me a connect exception: connection reset. port 3311 is forwarded and my firewall is turned off, so what causes the connection to reset ?

Thanks



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.