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