mil.dod.th.ose.time.service/src/mil/dod/th/ose/time/service/TimeChangeServiceThread.java
private long readData(final InputStream stream) throws IOException
    {
        //size of the long number that we are expecting to read from the stream.
        final int expectedBytesToRead = 8;
        
        final byte[] rcvBuffer = new byte[expectedBytesToRead];
        int bytesRemaining = expectedBytesToRead;
        while (bytesRemaining > 0)
        {
            try
            {
                final int bytesRead = stream.read(rcvBuffer, 
                        expectedBytesToRead - bytesRemaining, bytesRemaining);
                
                if (bytesRead == -1)
                {
                    return -1;
                }
                
                bytesRemaining -= bytesRead;
            }
            catch (final SocketException exception)
            {
                //don't want to log anything here. A timeout is expected.
                return SOCKET_READ_TO_VAL;
            }
        }
        
        final ByteBuffer buffer = ByteBuffer.wrap(rcvBuffer);
        
        return buffer.getLong();
    }
/**
     * Reads a <code>long</code> number from a given input stream.
     * @param stream
     *  the input stream to read the long number from
     * @return
     *  the <code>long</code> number if read was successful; -1 if EOF found;
     *  -2 if timeout has occurred; HEARTBEAT (-22) for heartbeat messages
     * @throws IOException
     *  if there is an exception while trying to read from the 
     *  input stream.
     */
Reads a long number from a given input stream.
@param stream
the input stream to read the long number from
@return
the long number if read was successful; -1 if EOF found;
-2 if timeout has occurred; HEARTBEAT (-22) for heartbeat messages
@throws IOException
if there is an exception while trying to read from the
input stream.
Reads a long number from a given input stream . @param stream the input stream to read the long number from @return the long number if read was successful ; - 1 if EOF found ; - 2 if timeout has occurred ; HEARTBEAT ( - 22 ) for heartbeat messages @throws IOException if there is an exception while trying to read from the input stream .
private long readData(final InputStream stream) throws IOException
    {
        final int expectedBytesToRead = 8;
        final byte[] rcvBuffer = new byte[expectedBytesToRead];
        int bytesRemaining = expectedBytesToRead;
        while (bytesRemaining > 0)
        {
            try
            {
                final int bytesRead = stream.read(rcvBuffer, 
                        expectedBytesToRead - bytesRemaining, bytesRemaining);
                if (bytesRead == -1)
                {
                    return -1;
                }
                bytesRemaining -= bytesRead;
            }
            catch (final SocketException exception)
            {
                return SOCKET_READ_TO_VAL;
            }
        }
        final ByteBuffer buffer = ByteBuffer.wrap(rcvBuffer);
        return buffer.getLong();
    }
private long readData ( final InputStream stream ) throws IOException { final int expectedBytesToRead = 8 ; final byte [ ] rcvBuffer = new byte [ expectedBytesToRead ] ; int bytesRemaining = expectedBytesToRead ; while ( bytesRemaining > 0 ) { try { final int bytesRead = stream . read ( rcvBuffer , expectedBytesToRead - bytesRemaining , bytesRemaining ) ; if ( bytesRead == - 1 ) { return - 1 ; } bytesRemaining -= bytesRead ; } catch ( final SocketException exception ) { return SOCKET_READ_TO_VAL ; } } final ByteBuffer buffer = ByteBuffer . wrap ( rcvBuffer ) ; return buffer . getLong ( ) ; }
Reads a <code>long</code> number from a given input stream.
Reads a <code > long< / code > number from a given input stream .
//size of the long number that we are expecting to read from the stream. //don't want to log anything here. A timeout is expected.