net.officefloor.plugin.socket.server.impl
Interface NonblockingSocketChannel


public interface NonblockingSocketChannel

Interface encapsulating the SocketChannel to provide the necessary non-blocking Socket operations.

Author:
Daniel Sagenschneider

Method Summary
 void close()
          Closes the underlying SocketChannel.
 InetSocketAddress getLocalAddress()
          Obtains the local address for this NonblockingSocketChannel.
 InetSocketAddress getRemoteAddress()
          Obtains the remote address to which this NonblockingSocketChannel is connected.
 int read(ByteBuffer buffer)
          Reads data from the SocketChannel.
 SelectionKey register(Selector selector, int ops, Object attachment)
          Registers the underlying SocketChannel with the input Selector.
 int write(ByteBuffer data)
          Writes the data to the SocketChannel.
 

Method Detail

register

SelectionKey register(Selector selector,
                      int ops,
                      Object attachment)
                      throws IOException
Registers the underlying SocketChannel with the input Selector.

Parameters:
selector - Selector.
ops - Operations as per SelectionKey.interestOps().
attachment - Attachment for the SelectionKey.
Returns:
SelectionKey of the resulting registration.
Throws:
IOException - If fails to register.

getLocalAddress

InetSocketAddress getLocalAddress()
Obtains the local address for this NonblockingSocketChannel.

Returns:
Local address for this NonblockingSocketChannel.

getRemoteAddress

InetSocketAddress getRemoteAddress()
Obtains the remote address to which this NonblockingSocketChannel is connected.

Returns:
Remote address to which this NonblockingSocketChannel is connected.

read

int read(ByteBuffer buffer)
         throws IOException
Reads data from the SocketChannel.

Parameters:
buffer - ByteBuffer to write data.
Returns:
Number of bytes read.
Throws:
IOException - If fails to read.

write

int write(ByteBuffer data)
          throws IOException
Writes the data to the SocketChannel.

Parameters:
data - ByteBuffer with the data to write.
Returns:
Number of bytes written.
Throws:
IOException - If fails to write.

close

void close()
           throws IOException
Closes the underlying SocketChannel.

Throws:
IOException - If fails to close.


Copyright © 2005-2011. All Rights Reserved.