|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucr.core.Connection
Represents a connection to an application communicating with the GNUTella protocol
Field Summary | |
static int |
CONNECTION_INCOMING
Connection created by another servant |
static int |
CONNECTION_OUTGOING
Connection created be JTella servant |
protected ConnectionData |
connectionData
|
private java.lang.Thread |
connectionThread
|
private static java.lang.String |
CRLF
|
protected double |
DROP_RATE
|
private GUID[] |
GUIDs
|
private int[] |
HITs
|
protected java.lang.String |
host
|
(package private) int |
idx
|
protected int |
inputCount
|
protected java.io.DataInputStream |
inputStream
|
protected java.io.BufferedReader |
inputStreamBuffer
|
private java.util.List |
messageBacklog
|
protected java.io.DataOutputStream |
outputStream
|
protected int |
port
|
protected Router |
router
|
private static java.lang.String |
SERVER_HELLO
|
private static java.lang.String |
SERVER_READY
|
private static java.lang.String |
SERVER_REJECT
|
protected boolean |
shutdownFlag
|
(package private) int |
SIZE
|
protected java.net.Socket |
socket
|
protected int |
status
|
static int |
STATUS_CONNECTING
Connection is attempting to connected to GNUTella |
static int |
STATUS_FAILED
Connection is not operating normally |
static int |
STATUS_OK
Connection is operating normally |
static int |
STATUS_STOPPED
Connection has been stopped |
protected int |
type
|
Constructor Summary | |
(package private) |
Connection(Router router,
java.net.Socket socket,
ConnectionData connectionData)
Construct the connection with an existing socket |
(package private) |
Connection(Router router,
java.lang.String host,
int port,
ConnectionData connectionData)
Construct the Connection using host/port information |
Method Summary | |
void |
add_query(GUID guid)
|
void |
dumpTable()
|
java.lang.String |
getConnectedServant()
Get the connected host |
(package private) java.lang.String |
getHost()
Retrieve the host this connection links to |
Host |
getHostConnectedServant()
Get the connected host |
int |
getStatus()
Get the current status of the connection |
int |
getType()
Get the type of connection, incoming or outgoing |
void |
incr_arrive(GUID guid,
int results)
|
private void |
initSocket()
Constructor helper |
int |
queryhits_arrived()
|
(package private) void |
send(Message m)
Sends a Message through this connection |
(package private) void |
sendAndReceive(Message m,
MessageReceiver receiver)
Sends a message down the connection and sends any response to MessageReceiver |
void |
shutdown()
Stops the connection and cleans up |
(package private) boolean |
startIncomingConnection(boolean accept)
Starts an incomming connection to a node on the network, does initial handshake |
(package private) boolean |
startOutgoingConnection(java.lang.String _MYPORT)
Starts an outgoing connection to a node on the network, does initial handshaking Initially we will send the other peer our PORT in order to let him know on which port are we accepting connenctions since MYIP+MYPORT provides a unique address for some host |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.Runnable |
run |
Field Detail |
public static final int STATUS_CONNECTING
public static final int STATUS_OK
public static final int STATUS_FAILED
public static final int STATUS_STOPPED
public static final int CONNECTION_INCOMING
public static final int CONNECTION_OUTGOING
private static java.lang.String CRLF
private static java.lang.String SERVER_HELLO
private static java.lang.String SERVER_READY
private static java.lang.String SERVER_REJECT
private java.util.List messageBacklog
private java.lang.Thread connectionThread
protected boolean shutdownFlag
protected java.net.Socket socket
protected java.io.DataInputStream inputStream
protected java.io.DataOutputStream outputStream
protected java.io.BufferedReader inputStreamBuffer
protected Router router
protected ConnectionData connectionData
protected java.lang.String host
protected int port
protected int status
protected int type
protected int inputCount
protected double DROP_RATE
int SIZE
private GUID[] GUIDs
private int[] HITs
int idx
Constructor Detail |
Connection(Router router, java.lang.String host, int port, ConnectionData connectionData) throws java.net.UnknownHostException, java.io.IOException
router
- message routerhost
- can be a machine name or IP addressport
- port to useConnection(Router router, java.net.Socket socket, ConnectionData connectionData) throws java.io.IOException
router
- message routersocket
- socket connection to another servantMethod Detail |
public void add_query(GUID guid)
public void incr_arrive(GUID guid, int results)
public int queryhits_arrived()
public void dumpTable()
private void initSocket() throws java.io.IOException
java.io.IOException
java.lang.String getHost()
public void shutdown()
boolean startOutgoingConnection(java.lang.String _MYPORT)
boolean startIncomingConnection(boolean accept)
accept
- is true to accept connection, false to reject
void sendAndReceive(Message m, MessageReceiver receiver) throws java.io.IOException
MessageReceiver
java.io.IOException
void send(Message m) throws java.io.IOException
m
- message
java.io.IOException
public java.lang.String getConnectedServant()
public Host getHostConnectedServant()
public int getStatus()
public int getType()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |