Rice Pastry API

rice.pastry.transport
Class SocketAdapter<Identifier>

java.lang.Object
  extended by rice.pastry.transport.SocketAdapter<Identifier>
All Implemented Interfaces:
P2PSocketReceiver<Identifier>, AppSocket

public class SocketAdapter<Identifier>
extends java.lang.Object
implements AppSocket, P2PSocketReceiver<Identifier>


Constructor Summary
SocketAdapter(P2PSocket<Identifier> socket, Environment env)
           
 
Method Summary
 void close()
          Closes this socket.
 long read(java.nio.ByteBuffer dst)
          Reads a sequence of bytes from this channel into a subsequence of the given buffers.
 long read(java.nio.ByteBuffer[] dsts, int offset, int length)
          Reads a sequence of bytes from this channel into a subsequence of the given buffers.
 void receiveException(P2PSocket<Identifier> s, java.lang.Exception e)
          Called when there is an error
 void receiveSelectResult(P2PSocket<Identifier> s, boolean canRead, boolean canWrite)
          Called when a socket is available for read/write
 void register(boolean wantToRead, boolean wantToWrite, int timeout, AppSocketReceiver receiver)
          Must be called every time a Read/Write occurs to continue operation.
 void shutdownOutput()
          Disables the output stream for this socket.
 java.lang.String toString()
           
 long write(java.nio.ByteBuffer src)
          Writes a sequence of bytes to this channel from a subsequence of the given buffers.
 long write(java.nio.ByteBuffer[] srcs, int offset, int length)
          Writes a sequence of bytes to this channel from a subsequence of the given buffers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocketAdapter

public SocketAdapter(P2PSocket<Identifier> socket,
                     Environment env)
Method Detail

close

public void close()
Description copied from interface: AppSocket
Closes this socket.

Specified by:
close in interface AppSocket

read

public long read(java.nio.ByteBuffer[] dsts,
                 int offset,
                 int length)
          throws java.io.IOException
Description copied from interface: AppSocket
Reads a sequence of bytes from this channel into a subsequence of the given buffers.

Specified by:
read in interface AppSocket
Throws:
java.io.IOException

register

public void register(boolean wantToRead,
                     boolean wantToWrite,
                     int timeout,
                     AppSocketReceiver receiver)
Description copied from interface: AppSocket
Must be called every time a Read/Write occurs to continue operation.

Specified by:
register in interface AppSocket
Parameters:
wantToRead - if you want to read from this socket
wantToWrite - if you want to write to this socket
timeout - // the socket's timeout value (this is a TCP level param)
receiver - will have receiveSelectResult() called on it note that you must call select() each time receiveSelectResult() is called. This is so your application can properly handle flow control

receiveException

public void receiveException(P2PSocket<Identifier> s,
                             java.lang.Exception e)
Description copied from interface: P2PSocketReceiver
Called when there is an error

Specified by:
receiveException in interface P2PSocketReceiver<Identifier>

receiveSelectResult

public void receiveSelectResult(P2PSocket<Identifier> s,
                                boolean canRead,
                                boolean canWrite)
                         throws java.io.IOException
Description copied from interface: P2PSocketReceiver
Called when a socket is available for read/write

Specified by:
receiveSelectResult in interface P2PSocketReceiver<Identifier>
Throws:
java.io.IOException

shutdownOutput

public void shutdownOutput()
Description copied from interface: AppSocket
Disables the output stream for this socket. Used to properly close down a socket used for bi-directional communication that can be initated by either side.

Specified by:
shutdownOutput in interface AppSocket

write

public long write(java.nio.ByteBuffer[] srcs,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from interface: AppSocket
Writes a sequence of bytes to this channel from a subsequence of the given buffers.

Specified by:
write in interface AppSocket
Throws:
java.io.IOException

read

public long read(java.nio.ByteBuffer dst)
          throws java.io.IOException
Description copied from interface: AppSocket
Reads a sequence of bytes from this channel into a subsequence of the given buffers.

Specified by:
read in interface AppSocket
Throws:
java.io.IOException

write

public long write(java.nio.ByteBuffer src)
           throws java.io.IOException
Description copied from interface: AppSocket
Writes a sequence of bytes to this channel from a subsequence of the given buffers.

Specified by:
write in interface AppSocket
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection