} else {
logger.trace("No Data left, need to wait for data ...");
offForRead=off;
lengthForRead=length;
DataPacket sp;
// IAN: enable asynchronous callback for data - only read when ready 8:)
sp = (DataPacket)waitForDataEvent();
logger.debug("Socket ID = " + _socketid + ", Sync unlocked, reading data now ... ");
if (isLocalDataConnection()) {
logger.debug("SocketInputStream read: retrieving local data now... Socket ID = " + _socketid);
System.arraycopy(localData,off,b,0,localData.length); // clean up data
return localData.length;
}
logger.debug("SocketInputStream read: Got remote data, parsing now.... ");
n = sp.getLength();
byte buf[] = new byte[b.length];
// acquire file descriptor and do the read
logger.debug("SocketInputStream read: copying to read buffer.... ");
System.arraycopy(sp.getData(),0,b,off,sp.getLength()); // copy data
logger.debug("SocketInputStream read: copied ok.... ");
/*
* We receive a "connection reset" but there may be bytes still
* buffered on the socket
*/
if (gotReset) {
impl.setConnectionResetPending();
System.arraycopy(sp.getData(),0,b,off,sp.getLength()); // copy data
if (n > 0) {
return n;
}
}
}