ucr.core
Class NetConnection

java.lang.Object
  extended byucr.core.NetConnection

public class NetConnection
extends java.lang.Object

The NetConnection represents a connection to the P2P network. The connection consists of one or more socket connections to servant nodes on the network.

The following is an example initiating a NetConnection.

     NetConnection c = new NetConnection("192.168.0.1", 6346);
     c.start();
 


Field Summary
private static ConnectionData connectionData
           
private  ConnectionList connectionList
           
private static java.lang.String greeting
           
private  HostCache hostCache
           
private static IncomingConnectionManager incomingConnectionManager
           
private static OutgoingConnectionManager outgoingConnectionManager
           
private  Router router
           
private static java.lang.String SERVER_READY
           
private  boolean shutdownFlag
           
 
Constructor Summary
NetConnection()
          Constructs an empty connection, the application must add a host cache or servant to generate activity
NetConnection(ConnectionData connData)
          Construct the connection specifying connection data.
NetConnection(ConnectionData connectionData, java.lang.String host, int port)
          Construct the connection, providing ConnectionData to initialize the connection and the address of a host cache servant
NetConnection(java.lang.String host, int port)
          Construct the connection using default connection data and the supplied information regarding the host cache on the network
 
Method Summary
 ServerSession createServerSession(MessageReceiver receiver)
          Creates a file serving session.
 Session createSession(MessageReceiver receiver)
          Creates a trace to find out information about the neighborhood
 ConnectionData getConnectionData()
          Get the ConnectionData settings
 java.util.LinkedList getConnectionList()
          Gets the current list of connections to GNUTella
 ConnectionList getConnections()
          Get the connection list
 HostCache getHostCache()
          Get the current HostCache.
 short[] getServantIdentifier()
          Get the servant identifier the NetConnection is using.
 void start()
          Starts the connection
 void stop()
          Stop the connection, after execution the NetConnection is unusable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

greeting

private static java.lang.String greeting

SERVER_READY

private static java.lang.String SERVER_READY

shutdownFlag

private boolean shutdownFlag

connectionData

private static ConnectionData connectionData

hostCache

private HostCache hostCache

connectionList

private ConnectionList connectionList

router

private Router router

incomingConnectionManager

private static IncomingConnectionManager incomingConnectionManager

outgoingConnectionManager

private static OutgoingConnectionManager outgoingConnectionManager
Constructor Detail

NetConnection

public NetConnection()
              throws java.net.UnknownHostException,
                     java.io.IOException
Constructs an empty connection, the application must add a host cache or servant to generate activity


NetConnection

public NetConnection(java.lang.String host,
                     int port)
              throws java.net.UnknownHostException,
                     java.io.IOException
Construct the connection using default connection data and the supplied information regarding the host cache on the network

Parameters:
host - can be a machine name or IP address
port - port to use

NetConnection

public NetConnection(ConnectionData connData)
              throws java.net.UnknownHostException,
                     java.io.IOException
Construct the connection specifying connection data. The connection will not have access to a host cache unless specified later.

Parameters:
connData - connection data

NetConnection

public NetConnection(ConnectionData connectionData,
                     java.lang.String host,
                     int port)
              throws java.net.UnknownHostException,
                     java.io.IOException
Construct the connection, providing ConnectionData to initialize the connection and the address of a host cache servant

Parameters:
connectionData - configuration data for the connection
host - can be a machine name or IP address
port - to use
Method Detail

start

public void start()
Starts the connection


stop

public void stop()
Stop the connection, after execution the NetConnection is unusable. A new connection must be created if needed. If a temporary disconnect from NodeConnections is desired, the connection count requests can be set to 0


getHostCache

public HostCache getHostCache()
Get the current HostCache. Using the HostCache an application can query the known hosts, and add and remove hosts

Returns:
host cache

getConnectionData

public ConnectionData getConnectionData()
Get the ConnectionData settings

Returns:
connection data

createSession

public Session createSession(MessageReceiver receiver)
Creates a trace to find out information about the neighborhood

Parameters:
receiver - receiver for search responses
Returns:
session

createServerSession

public ServerSession createServerSession(MessageReceiver receiver)
Creates a file serving session. FileServerSession can respond with a query hit

Parameters:
receiver - message receiver

getConnectionList

public java.util.LinkedList getConnectionList()
Gets the current list of connections to GNUTella

Returns:
list of connections

getConnections

public ConnectionList getConnections()
Get the connection list


getServantIdentifier

public short[] getServantIdentifier()
Get the servant identifier the NetConnection is using. The servant identifier is used in connection with Push message processing

Returns:
servant identifier