[xSocket-develop] Connection closed after 2 packets
Status: Inactive
Brought to you by:
grro
|
From: Jens R. <jen...@ju...> - 2008-12-12 12:38:37
|
Hello,
I have a big problem.
I am new to xSocket and my written Server close every connection after
two packets without reason.
The packagesize is equal.
Example:
The first 2 bytes of data are the length of all data, that the client
send. In this example 1492 bytes. With the nbc.readByte-Method i try to
read all 1492 bytes. But after 2 packages (for e.g. 500 bytes) the Sever
close the connection and System.out.println is never reached.
I looked with wireshark and after the first packege the server send ACK,
after the second the server send ACK and FIN,ACK.
The Code:
public boolean onData(INonBlockingConnection nbc) throws IOException,
BufferUnderflowException, ClosedChannelException,
MaxReadSizeExceededException {
byte[] lengthArray = new byte[2];
for (int i=0; i<2; i++) {
lengthArray[i] =
ByteKit.fromUnsignedInt(nbc.readByte()); // Reads the complete length of
data the client send
}
int length =
ByteKit.chartoInt((byte)0,(byte)0,lengthArray[0],lengthArray[1]); // The
length of data
byte dataArray[] = new byte[length];
dataArray = nbc.readBytesByLength(length); // Read all data
in array
System.out.println("Done"!); // Never reached
}
Has anybody an idea.
Best regards.
Jens
|