I have the following code to read data from a socket.
byte[] data = new byte[dataLength];
if(dataLength > 2000000)FileManager.writeToLogFile(this.getClass(), "GetIncomingMessages", LogMessageType.DEBUG, "XXXXYYYY => 2 length: " + dataLength);
for(int i = 0 ; i < dataLength ; i++){
byte[] temp = new byte[1];
in.read(temp);
data[i] = temp[0];
}
if(dataLength > 2000000)FileManager.writeToLogFile(this.getClass(), "GetIncomingMessages", LogMessageType.DEBUG, "XXXXYYYY => 3 length: " + dataLength);
This code works fine until I get a pack with the size of around 3MB (3227056 bytes to be exact). When this packet is received, no exception occurs, neither does my program crash, but the code never progresses beyond that point. Basically the last log entry that you see above is not made.
What could be the reason for this ? How could I at least figure out WHAT the error is ? (Error is not caught in any of the try-catch blocks). There are however, other receives that take place beyond this point.
Try:
This should make for speed up.
Note that this is not really a solution to your problem. But I guess the inefficient loop to be a part of it. Hopefully we can edit this answer to come to a solution for you.