jitsi/ice4j

PseudoTcpSocket input stream doesn't support readNBytes

indiscrete-void opened this issue · 0 comments

Calling readNBytes on InputStream of pseudo tcp socket instance, causes it to hang in loop forever.
I think this behavior is caused by PseudoTcpInputStream#read(byte[], int, int) implementation which doesn't know how to handle length of zero, i.e. when length of zero is provided it loops forever because in these lines:

read = pseudoTcp.recv(buffer, offset, length);

read = pseudoTcp.recv(buffer, offset, length);
if (logger.isLoggable(Level.FINER))
{
    logger.log(Level.FINER,
               "Read Recv read count: " + read);
}
if (read > 0)
{
    return read;
}

read is never more than zero, if length=0