org.xvsm.lookup.gnutella
Class GnutellaPeer

Package class diagram package GnutellaPeer
java.lang.Object
  extended by org.xvsm.lookup.gnutella.GnutellaPeer

public class GnutellaPeer
extends java.lang.Object

Is the class that handles the Gnutella functions of a peer.

Author:
Hannu-Daniel Goiss

Constructor Summary
GnutellaPeer(int port, java.lang.String serverIp, int serverPort)
          Constructor to initiate a peer using the local port and the server ip-address as well as the port of the server
 
Method Summary
 void connect()
          connects the peer to the server to retrieve some addresses of other peers
 java.util.Hashtable<java.lang.String,java.lang.Object> getAnswer()
           
 java.util.Hashtable<java.lang.String,java.lang.Object> getList()
          returns the list of objects, which have been published
 int getLocalPort()
           
 java.lang.String getServerIp()
           
 int getServerPort()
           
static void main(java.lang.String[] args)
          starting a standalone peer.
 void publish(java.lang.String searchString, java.lang.Object object)
          adds an additional object to the list of objects, which have been published
 java.lang.Object search(java.lang.String searchString)
          function to search for an object in the gnutella network by its string.
 void senden(GnutellaRequest request, boolean throwException)
          sends a request to another peer.
 void unpublish(java.lang.String searchString)
          removes an object for the list of objects, which have been published
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GnutellaPeer

public GnutellaPeer(int port,
                    java.lang.String serverIp,
                    int serverPort)
             throws java.net.UnknownHostException,
                    java.io.IOException,
                    java.lang.ClassNotFoundException
Constructor to initiate a peer using the local port and the server ip-address as well as the port of the server

Parameters:
port -
serverIp -
serverPort -
Throws:
java.net.UnknownHostException
java.io.IOException
java.lang.ClassNotFoundException
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
starting a standalone peer. Simply used for testing

Parameters:
args -
Throws:
java.io.IOException
java.lang.ClassNotFoundException

connect

public void connect()
             throws java.net.UnknownHostException,
                    java.io.IOException,
                    java.lang.ClassNotFoundException
connects the peer to the server to retrieve some addresses of other peers

Throws:
java.net.UnknownHostException
java.io.IOException
java.lang.ClassNotFoundException

getList

public java.util.Hashtable<java.lang.String,java.lang.Object> getList()
returns the list of objects, which have been published

Returns:

publish

public void publish(java.lang.String searchString,
                    java.lang.Object object)
adds an additional object to the list of objects, which have been published

Parameters:
searchString -
object -

unpublish

public void unpublish(java.lang.String searchString)
removes an object for the list of objects, which have been published

Parameters:
searchString -

senden

public void senden(GnutellaRequest request,
                   boolean throwException)
            throws NotFoundException,
                   java.net.UnknownHostException,
                   java.io.IOException,
                   java.lang.ClassNotFoundException
sends a request to another peer. This function should not be used by users of this api. The search function should be used instead.

Parameters:
request -
throwException -
Throws:
NotFoundException
java.net.UnknownHostException
java.io.IOException
java.lang.ClassNotFoundException

search

public java.lang.Object search(java.lang.String searchString)
                        throws java.net.UnknownHostException,
                               java.io.IOException,
                               java.lang.ClassNotFoundException,
                               NotFoundException
function to search for an object in the gnutella network by its string.

Parameters:
searchString -
Returns:
Throws:
java.net.UnknownHostException
java.io.IOException
java.lang.ClassNotFoundException
NotFoundException

getLocalPort

public int getLocalPort()

getServerIp

public java.lang.String getServerIp()

getServerPort

public int getServerPort()

getAnswer

public java.util.Hashtable<java.lang.String,java.lang.Object> getAnswer()


Copyright © 2009. All Rights Reserved.