I have a thread that is supposed to listen for acknowledgements of messages and process them, but it seems that the thread is never reciving the acknowledgements.
Here is the relevant code in the thread:
private class TcpReader extends Thread {
BufferedReader reader;
boolean running = false;
public TcpReader(BufferedReader reader)
{
this.reader = reader;
}
public void run() {
running = true;
while (running) {
try {
String line = reader.readLine();
logger.debug("TCP READER RECIEVED MESSAGE ["+ line + "]");
// Do stuff
} catch (Exception e) {
}
}
}
}
The thread is created in the following code which happens in a different class:
sock = new Socket(hostName, port);
out = new PrintWriter(sock.getOutputStream(), true);
isConnected = true;
BufferedReader reader =
new BufferedReader(new InputStreamReader(sock.getInputStream()));
tcpReader = new TcpReader(reader);
tcpReader.start();
The Variables are instantiated in the as member variables:
Socket sock;
PrintWriter out;
BufferedReader in;
The flow of execution is my server class recives a message and then replies with an ACK that the client is supposed to pick up on. However since the client is not to wait for the ack to continue A separate thread waits for all responses.
The readline code never reads anything.
The messages are being sent from my server and they have "\r\n" as their last two chars.