private DMessage rxMessage() throws IOException {
  int size=-1;
  int command=0;
  try {
    size=(int)readDWord();
    command=(int)readDWord();
  }
 catch (  SocketTimeoutException e) {
    if (!m_detectBrokenSocket)     throw e;
    int oldBufferSize=-1;
    if (m_socket != null) {
      oldBufferSize=m_socket.getSendBufferSize();
      m_socket.setSendBufferSize(1);
    }
    SendThread t=new SendThread();
    t.start();
    long waitBegin=System.currentTimeMillis();
    while (true) {
      try {
        t.join(1000);
        if (t.completed)         break;
      }
 catch (      InterruptedException e1) {
        break;
      }
      long waitEnd=System.currentTimeMillis();
      if (waitEnd - waitBegin > 10000)       break;
    }
    boolean success=true;
    if (t.isAlive()) {
      t.interrupt();
      success=false;
    }
    if (oldBufferSize > 0) {
      m_socket.setSendBufferSize(oldBufferSize);
    }
    if (!t.completed) {
      success=false;
    }
    if (t.exception != null) {
      throw t.exception;
    }
    if (success)     throw e;
 else     throw new SocketException("Broken pipe");
  }
  if (size < 0)   throw new IOException("socket closed");
  DMessage message=DMessageCache.alloc(size);
  byte[] messageContent=message.getData();
  int offset=0;
  while (offset < size)   offset+=m_in.read(messageContent,offset,size - offset);
  message.setType(command);
synchronized (this) {
    m_msgRx++;
  }
  return message;
}

private DMessage rxMessage ( ) throws IOException { int size = - 1 ; int command = 0 ; try { size = ( int ) readDWord ( ) ; command = ( int ) readDWord ( ) ; } catch ( SocketTimeoutException e ) { if ( ! m_detectBrokenSocket ) throw e ; int oldBufferSize = - 1 ; if ( m_socket != null ) { oldBufferSize = m_socket . getSendBufferSize ( ) ; m_socket . setSendBufferSize ( 1 ) ; } SendThread t = new SendThread ( ) ; t . start ( ) ; long waitBegin = System . currentTimeMillis ( ) ; while ( true ) { try { t . join ( 1000 ) ; if ( t . completed ) break ; } catch ( InterruptedException e1 ) { break ; } long waitEnd = System . currentTimeMillis ( ) ; if ( waitEnd - waitBegin > 10000 ) break ; } boolean success = true ; if ( t . isAlive ( ) ) { t . interrupt ( ) ; success = false ; } if ( oldBufferSize > 0 ) { m_socket . setSendBufferSize ( oldBufferSize ) ; } if ( ! t . completed ) { success = false ; } if ( t . exception != null ) { throw t . exception ; } if ( success ) throw e ; else throw new SocketException ( "Broken pipe" ) ; } if ( size < 0 ) throw new IOException ( "socket closed" ) ; DMessage message = DMessageCache . alloc ( size ) ; byte [ ] messageContent = message . getData ( ) ; int offset = 0 ; while ( offset < size ) offset += m_in . read ( messageContent , offset , size - offset ) ; message . setType ( command ) ; synchronized ( this ) { m_msgRx ++ ; } return message ; }
get the next message on the input stream , using the context contained within the message itself to demark its end
