public void write( ByteBuffer data ) { checkClosed(); try { out.write(data.array(), data.position(), data.remaining()); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } }
public void close() { checkClosed(); try { Socket temp = sock; sock = null; connected.set(false); temp.close(); } catch( IOException e ) { throw new ConnectorException( "Error closing socket for:" + remoteAddress, e ); } }
public boolean available() { checkClosed(); try { return in.available() > 0; } catch( IOException e ) { throw new ConnectorException( "Error retrieving data availability for:" + remoteAddress, e ); } }
public ByteBuffer read() { checkClosed(); try { // Read what we can int count = in.read(buffer); if( count < 0 ) { // Socket is closed close(); return null; } // Wrap it in a ByteBuffer for the caller return ByteBuffer.wrap( buffer, 0, count ); } catch( IOException e ) { if( !connected.get() ) { // Nothing to see here... just move along return null; } throw new ConnectorException( "Error reading from connection to:" + remoteAddress, e ); } }
public boolean available() { checkClosed(); try { return in.available() > 0; } catch( IOException e ) { throw new ConnectorException( "Error retrieving data availability for:" + remoteAddress, e ); } }
public void close() { checkClosed(); try { Socket temp = sock; sock = null; connected.set(false); temp.close(); } catch( IOException e ) { throw new ConnectorException( "Error closing socket for:" + remoteAddress, e ); } }
public void write( ByteBuffer data ) { checkClosed(); try { out.write(data.array(), data.position(), data.remaining()); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } }
public void close() { checkClosed(); try { Socket temp = sock; sock = null; connected.set(false); temp.close(); } catch( IOException e ) { throw new ConnectorException( "Error closing socket for:" + remoteAddress, e ); } }
public boolean available() { checkClosed(); try { return in.available() > 0; } catch( IOException e ) { throw new ConnectorException( "Error retrieving data availability for:" + remoteAddress, e ); } }
public void write( ByteBuffer data ) { checkClosed(); try { out.write(data.array(), data.position(), data.remaining()); } catch( IOException e ) { throw new ConnectorException( "Error writing to connection:" + remoteAddress, e ); } }
public ByteBuffer read() { checkClosed(); try { // Read what we can int count = in.read(buffer); if( count < 0 ) { // Socket is closed close(); return null; } // Wrap it in a ByteBuffer for the caller return ByteBuffer.wrap( buffer, 0, count ); } catch( IOException e ) { if( !connected.get() ) { // Nothing to see here... just move along return null; } throw new ConnectorException( "Error reading from connection to:" + remoteAddress, e ); } }
public ByteBuffer read() { checkClosed(); try { // Read what we can int count = in.read(buffer); if( count < 0 ) { // Socket is closed close(); return null; } // Wrap it in a ByteBuffer for the caller return ByteBuffer.wrap( buffer, 0, count ); } catch( IOException e ) { if( !connected.get() ) { // Nothing to see here... just move along return null; } throw new ConnectorException( "Error reading from connection to:" + remoteAddress, e ); } }