Code example for SocketChannel

Methods: read

0
 
  /** 
   * Perform a nonblocking read into buffer. 
   */ 
  public int read(ByteBuffer buffer) throws IOException {
    return socketChannel_.read(buffer);
  } 
 
 
  /** 
   * Reads from the underlying input stream if not null. 
   */ 
  public int read(byte[] buf, int off, int len) throws TTransportException {
    if ((socketChannel_.validOps() & SelectionKey.OP_READ) != SelectionKey.OP_READ) {
      throw new TTransportException(TTransportException.NOT_OPEN, 
        "Cannot read from write-only socket channel"); 
    } 
    try { 
      return socketChannel_.read(ByteBuffer.wrap(buf, off, len));
    } catch (IOException iox) {
      throw new TTransportException(TTransportException.UNKNOWN, iox);