* @param iCommand
* @return
* @throws IOException
*/
protected OChannelBinaryClient beginRequest(final byte iCommand) throws IOException {
OChannelBinaryClient network = null;
// FIND THE FIRST FREE CHANNEL AVAILABLE
lock.acquireSharedLock();
try {
while (network == null) {
if (networkPoolCursor >= networkPool.size())
networkPoolCursor = 0;
network = networkPool.get(networkPoolCursor);
if (network.getLockWrite().tryLock())
break;
networkPoolCursor++;
}
} finally {
lock.releaseSharedLock();
}
network.writeByte(iCommand);
network.writeInt(getSessionId());
return network;
}