|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrice.selector.SelectionKeyHandler
rice.pastry.socket.SocketAppSocket
public class SocketAppSocket
Private class which is tasked with reading the greeting message off of a newly connected socket. This greeting message says who the socket is coming from, and allows the connected to hand the socket off the appropriate node handle.
Field Summary | |
---|---|
protected java.nio.channels.SocketChannel |
channel
DESCRIBE THE FIELD |
static byte |
CONNECTION_NO_ACCEPTOR
DESCRIBE THE FIELD |
static byte |
CONNECTION_NO_APP
DESCRIBE THE FIELD |
static byte |
CONNECTION_OK
DESCRIBE THE FIELD |
static byte |
CONNECTION_UNKNOWN
DESCRIBE THE FIELD |
static byte |
CONNECTION_UNKNOWN_ERROR
DESCRIBE THE FIELD |
protected java.nio.channels.SelectionKey |
key
DESCRIBE THE FIELD |
protected AppSocketReceiver |
reader
DESCRIBE THE FIELD |
protected AppSocketReceiver |
receiver
DESCRIBE THE FIELD |
protected AppSocketReceiver |
writer
DESCRIBE THE FIELD |
Constructor Summary | |
---|---|
SocketAppSocket(SocketCollectionManager manager,
java.nio.channels.SelectionKey key,
int appId)
Constructor which accepts an incoming connection, represented by the selection key. |
|
SocketAppSocket(SocketCollectionManager manager,
SourceRoute path,
int appId,
AppSocketReceiver receiver,
int timeout)
Constructor which creates an outgoing connection to the given node handle using the provided address as a source route intermediate node. |
Method Summary | |
---|---|
protected void |
acceptConnection(java.nio.channels.SelectionKey key)
Accepts a new connection on the given key |
void |
close()
Method which closes down this socket manager, by closing the socket, cancelling the key and setting the key to be interested in nothing |
void |
connect(java.nio.channels.SelectionKey key)
Specified by the SelectionKeyHandler interface - calling this tells this socket manager that the connection has completed and we can now read/write. |
protected void |
createConnection(SourceRoute path)
Creates the outgoing socket to the remote handle |
void |
modifyKey(java.nio.channels.SelectionKey key)
Method which should change the interestOps of the handler's key. |
long |
read(java.nio.ByteBuffer[] dsts,
int offset,
int length)
DESCRIBE THE METHOD |
void |
read(java.nio.channels.SelectionKey key)
Reads from the socket attached to this connector. |
void |
register(boolean wantToRead,
boolean wantToWrite,
int timeout,
AppSocketReceiver receiver)
DESCRIBE THE METHOD |
void |
shutdownOutput()
Method which initiates a shutdown of this socket by calling shutdownOutput(). |
java.lang.String |
toString()
Converts to a String representation of the object. |
long |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length)
DESCRIBE THE METHOD |
void |
write(java.nio.channels.SelectionKey key)
Writes to the socket attached to this socket manager. |
Methods inherited from class rice.selector.SelectionKeyHandler |
---|
accept |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.nio.channels.SelectionKey key
protected java.nio.channels.SocketChannel channel
protected AppSocketReceiver receiver
protected AppSocketReceiver reader
protected AppSocketReceiver writer
public static final byte CONNECTION_UNKNOWN_ERROR
public static final byte CONNECTION_UNKNOWN
public static final byte CONNECTION_OK
public static final byte CONNECTION_NO_APP
public static final byte CONNECTION_NO_ACCEPTOR
Constructor Detail |
---|
public SocketAppSocket(SocketCollectionManager manager, java.nio.channels.SelectionKey key, int appId) throws java.io.IOException
manager
- TODOkey
- The server accepting key for the channelappId
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic SocketAppSocket(SocketCollectionManager manager, SourceRoute path, int appId, AppSocketReceiver receiver, int timeout) throws java.io.IOException
manager
- TODOpath
- DESCRIBE THE PARAMETERappId
- DESCRIBE THE PARAMETERreceiver
- DESCRIBE THE PARAMETERtimeout
- DESCRIBE THE PARAMETER
java.io.IOException
- An errorMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public void shutdownOutput()
shutdownOutput
in interface AppSocket
public void close()
close
in interface AppSocket
public void modifyKey(java.nio.channels.SelectionKey key)
modifyKey
in class SelectionKeyHandler
key
- The key in questionpublic void connect(java.nio.channels.SelectionKey key)
connect
in class SelectionKeyHandler
key
- The key which is connectable.public void read(java.nio.channels.SelectionKey key)
read
in class SelectionKeyHandler
key
- The selection key for this managerpublic void write(java.nio.channels.SelectionKey key)
write
in class SelectionKeyHandler
key
- The selection key for this managerprotected void acceptConnection(java.nio.channels.SelectionKey key) throws java.io.IOException
key
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONprotected void createConnection(SourceRoute path) throws java.io.IOException
path
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException
read
in interface AppSocket
dsts
- DESCRIBE THE PARAMETERoffset
- DESCRIBE THE PARAMETERlength
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write
in interface AppSocket
srcs
- DESCRIBE THE PARAMETERoffset
- DESCRIBE THE PARAMETERlength
- DESCRIBE THE PARAMETER
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic void register(boolean wantToRead, boolean wantToWrite, int timeout, AppSocketReceiver receiver)
register
in interface AppSocket
wantToRead
- DESCRIBE THE PARAMETERwantToWrite
- DESCRIBE THE PARAMETERtimeout
- DESCRIBE THE PARAMETERreceiver
- DESCRIBE THE PARAMETER
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |