|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object seda.sandStorm.lib.Gnutella.GnutellaServer
public class GnutellaServer
A GnutellaServer is a SandStorm stage which allows outgoing connections to be established to the Gnutella network, and accepts incoming connections. The server has a client sink associated with it, onto which GnutellaConnection and GnutellaPacket events are pushed. When a connection is closed, a SinkClosedEvent is pushed, with the sink pointer set to the GnutellaConnection that closed. If a an outgoing connection fails, a GnutellaConnectFailedevent is pushed.
GnutellaConnection, GnutellaPacket
Nested Class Summary | |
---|---|
(package private) class |
GnutellaServer.connectionState
Internal class used to monitor state of connections during handshake phase |
Field Summary | |
---|---|
private boolean |
acceptIncoming
|
private java.util.Vector |
activeConnections
|
private SinkIF |
clientSink
|
private ATcpClientSocket |
clisock
|
private static byte[] |
connectMsg
|
private static byte[] |
connectReplyMsg
|
private boolean |
connectUpstream
|
private java.util.Hashtable |
connTable
|
private static boolean |
DEBUG
|
private java.lang.String |
hostname
|
private int |
listenPort
|
private ManagerIF |
mgr
|
private SinkIF |
mySink
|
private java.util.Hashtable |
newConnTable
|
private static int |
num_svrs
|
private java.util.Hashtable |
pendingConnTable
|
private int |
port
|
private java.util.Hashtable |
readerTable
|
private ATcpServerSocket |
servsock
|
Fields inherited from interface seda.sandStorm.lib.Gnutella.GnutellaConst |
---|
DEFAULT_DOWNLOAD_PORT, DEFAULT_GNUTELLA_PORT, DEFAULT_HOPS, DEFAULT_PING_INTERVAL, DEFAULT_SPEED, DEFAULT_TTL, GNUTELLA_CONNECT, GNUTELLA_FN_PING, GNUTELLA_FN_PONG, GNUTELLA_FN_PUSH, GNUTELLA_FN_QUERY, GNUTELLA_FN_QUERYHITS, GNUTELLA_OK, MAX_PAYLOAD_SIZE, PACKET_HEADER_SIZE, WRITE_CLOG_THRESHOLD |
Constructor Summary | |
---|---|
GnutellaServer(ManagerIF mgr,
SinkIF clientSink)
Create a Gnutella server listening for incoming connections on the default port of 6346. |
|
GnutellaServer(ManagerIF mgr,
SinkIF clientSink,
int listenPort)
Create a Gnutella server listening for incoming connections on the given listenPort. |
Method Summary | |
---|---|
(package private) void |
cleanupConnection(ATcpConnection tcpconn,
GnutellaConnection gc)
|
(package private) void |
closeConnection(ATcpConnection tcpconn,
SinkIF compQ)
|
private void |
continuePacket(ATcpInPacket pkt)
|
void |
destroy()
Called when an event handler is destroyed. |
(package private) SinkIF |
getSink()
|
void |
handleEvent(QueueElementIF qel)
Handle the event corresponding to the given QueueElementIF. |
void |
handleEvents(QueueElementIF[] qelarr)
Handle the events corresponding to the given QueueElementIF array. |
private void |
handleHandshake(ATcpInPacket pkt)
|
private void |
handleIncomingConnection(ATcpConnection conn)
|
void |
init(ConfigDataIF config)
Called when an event handler is initialized. |
void |
openConnection(java.net.InetAddress address,
int port)
Open a connection to the given address and port. |
void |
openConnection(java.lang.String hostname,
int port)
Open a connection to the given hostname and port. |
private void |
pushNewConnection(ATcpConnection conn)
|
void |
registerSink(SinkIF sink)
Register a sink to receive incoming packets on this connection. |
private void |
sendBytes(SinkIF sink,
byte[] msg)
|
void |
sendToAllButOne(GnutellaPacket pkt,
GnutellaConnection exclude)
Send a packet to all nodes but the given node. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
private boolean acceptIncoming
private boolean connectUpstream
private java.lang.String hostname
private int port
private int listenPort
private ATcpServerSocket servsock
private ATcpClientSocket clisock
private ManagerIF mgr
private SinkIF mySink
private SinkIF clientSink
private java.util.Hashtable readerTable
private java.util.Hashtable connTable
private java.util.Hashtable newConnTable
private java.util.Hashtable pendingConnTable
private java.util.Vector activeConnections
private static int num_svrs
private static byte[] connectMsg
private static byte[] connectReplyMsg
Constructor Detail |
---|
public GnutellaServer(ManagerIF mgr, SinkIF clientSink) throws java.lang.Exception
java.lang.Exception
public GnutellaServer(ManagerIF mgr, SinkIF clientSink, int listenPort) throws java.lang.Exception
java.lang.Exception
Method Detail |
---|
public void init(ConfigDataIF config) throws java.io.IOException
EventHandlerIF
init
in interface EventHandlerIF
config
- The set of configuration parameters for the stage.
java.io.IOException
public void destroy()
EventHandlerIF
destroy
in interface EventHandlerIF
public void openConnection(java.lang.String hostname, int port) throws java.net.UnknownHostException
java.net.UnknownHostException
public void openConnection(java.net.InetAddress address, int port)
public void handleEvent(QueueElementIF qel)
EventHandlerIF
handleEvent
in interface EventHandlerIF
public void handleEvents(QueueElementIF[] qelarr)
EventHandlerIF
handleEvents
in interface EventHandlerIF
private void continuePacket(ATcpInPacket pkt)
private void handleIncomingConnection(ATcpConnection conn)
private void pushNewConnection(ATcpConnection conn)
void closeConnection(ATcpConnection tcpconn, SinkIF compQ)
void cleanupConnection(ATcpConnection tcpconn, GnutellaConnection gc)
private void handleHandshake(ATcpInPacket pkt)
private void sendBytes(SinkIF sink, byte[] msg)
public java.lang.String toString()
toString
in class java.lang.Object
public void registerSink(SinkIF sink)
SinkIF getSink()
public void sendToAllButOne(GnutellaPacket pkt, GnutellaConnection exclude)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |