So I'm trying to set up a Client <-> Server connection. I keep getting the most annoying error because the client and server will not connect but only send "cpc" once when I call
This is the code which I am using. This is contained in a class which extends Thread.
There error is where 'while ((inputLine = in.readLine()) != null) {' is located.
Here is the error if any of you need it.
Heres the print() code
print("cpc");
This is the code which I am using. This is contained in a class which extends Thread.
BufferedReader in = null;
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String inputLine, outputLine;
print("cpc");
try{
while ((inputLine = in.readLine()) != null) {
outputLine = process(inputLine);
if (!outputLine.equals("")){
print(outputLine);
}
}
} catch (Exception e){
e.printStackTrace();
}
There error is where 'while ((inputLine = in.readLine()) != null) {' is located.
Here is the error if any of you need it.
Quote
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at javaclient.Client.run(Client.java:28)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at javaclient.Client.run(Client.java:28)
Heres the print() code
public void print(String s){
out.println(s);
}