Can't seem to understand why my while loop doesn't exit!
I'm gonna past a small piece of code that reads data from a socket server coming from flash, and then sends it back to a client, this is the code:
Code:
public void run()
{
try
{
char charBuffer[] = new char[1];
while(in.read(charBuffer,0,1) != -1)
{
StringBuffer stringBuffer = new StringBuffer(8192);
while(charBuffer[0] != '\0')
{
System.out.println("loop 2");
stringBuffer.append(charBuffer[0]);
in.read(charBuffer, 0 ,1);
}
System.out.println("Sending message");
server.sendMessage(stringBuffer.toString(),this);
}
}
catch(IOException ioe)
{
}
finally
{
killClient();
}
}
The first while loop checks if it's possible to read data, but it will return false if there is none right? That would mean that the while loop will not execute and it will kill the client, but that doesn't happen until I actually disconnect.
Can someone help me with this small but annoying thing I have going on? I just can't seem to find the logic why it doesn't execute the finally block