|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.selector.SelectionKeyHandler org.mpisws.p2p.transport.wire.SocketManager
public class SocketManager
Field Summary | |
---|---|
protected java.nio.channels.SocketChannel |
channel
|
protected java.nio.channels.SelectionKey |
key
|
protected P2PSocketReceiver<java.net.InetSocketAddress> |
reader
|
protected TCPLayer |
tcp
|
protected TimerTask |
timer
|
protected P2PSocketReceiver<java.net.InetSocketAddress> |
writer
|
Constructor Summary | |
---|---|
SocketManager(TCPLayer tcp,
java.net.InetSocketAddress addr,
SocketCallback<java.net.InetSocketAddress> c,
java.util.Map<java.lang.String,java.lang.Object> options)
Constructor which creates an outgoing connection to the given node handle using the provided address as a source route intermediate node. |
|
SocketManager(TCPLayer tcp,
java.nio.channels.SelectionKey serverKey)
Constructor which accepts an incoming connection, represented by the selection key. |
Method Summary | |
---|---|
boolean |
cancel()
|
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 |
java.net.InetSocketAddress |
getIdentifier()
The identification of the node at the other end of the socket. |
java.util.Map<java.lang.String,java.lang.Object> |
getOptions()
Details on the connectivity of the socket (encrypted, source-routed etc) |
java.nio.channels.SocketChannel |
getSocketChannel()
|
void |
modifyKey(java.nio.channels.SelectionKey key)
Method which should change the interestOps of the handler's key. |
long |
read(java.nio.ByteBuffer dst)
Reads a sequence of bytes from this channel into a subsequence of the given buffer. |
void |
read(java.nio.channels.SelectionKey key)
Reads from the socket attached to this connector. |
void |
register(boolean wantToRead,
boolean wantToWrite,
P2PSocketReceiver<java.net.InetSocketAddress> receiver)
Must be called every time a Read/Write occurs to continue operation. |
void |
shutdownOutput()
Method which initiates a shutdown of this socket by calling shutdownOutput(). |
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. |
void |
write(java.nio.channels.SelectionKey key)
Writes to the socket attached to this socket manager. |
Methods inherited from class rice.selector.SelectionKeyHandler |
---|
accept, connect |
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 TimerTask timer
protected TCPLayer tcp
protected P2PSocketReceiver<java.net.InetSocketAddress> reader
protected P2PSocketReceiver<java.net.InetSocketAddress> writer
Constructor Detail |
---|
public SocketManager(TCPLayer tcp, java.nio.channels.SelectionKey serverKey) throws java.io.IOException
key
- The server accepting key for the channelmanager
- TODO
java.io.IOException
- DESCRIBE THE EXCEPTIONpublic SocketManager(TCPLayer tcp, java.net.InetSocketAddress addr, SocketCallback<java.net.InetSocketAddress> c, java.util.Map<java.lang.String,java.lang.Object> options) throws java.io.IOException
manager
- TODOaddress
- The ultimate destination of this socketproxy
- The intermediate destination of this socket (if a source route)
java.io.IOException
- An errorMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public void close()
close
in interface P2PSocket<java.net.InetSocketAddress>
public void modifyKey(java.nio.channels.SelectionKey key)
modifyKey
in class SelectionKeyHandler
key
- The key in questionpublic 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 managerpublic void register(boolean wantToRead, boolean wantToWrite, P2PSocketReceiver<java.net.InetSocketAddress> receiver)
P2PSocket
register
in interface P2PSocket<java.net.InetSocketAddress>
wantToRead
- if you want to read from this socketwantToWrite
- if you want to write to this socketreceiver
- 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 controlpublic void shutdownOutput()
shutdownOutput
in interface P2PSocket<java.net.InetSocketAddress>
public long read(java.nio.ByteBuffer dst) throws java.io.IOException
P2PSocket
read
in interface P2PSocket<java.net.InetSocketAddress>
java.io.IOException
public long write(java.nio.ByteBuffer src) throws java.io.IOException
P2PSocket
write
in interface P2PSocket<java.net.InetSocketAddress>
java.io.IOException
public boolean cancel()
cancel
in interface Cancellable
public java.net.InetSocketAddress getIdentifier()
P2PSocket
getIdentifier
in interface P2PSocket<java.net.InetSocketAddress>
getIdentifier
in interface SocketRequestHandle<java.net.InetSocketAddress>
public java.util.Map<java.lang.String,java.lang.Object> getOptions()
P2PSocket
getOptions
in interface P2PSocket<java.net.InetSocketAddress>
getOptions
in interface SocketRequestHandle<java.net.InetSocketAddress>
public java.nio.channels.SocketChannel getSocketChannel()
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |