com.limegroup.gnutella
Class UDPService

java.lang.Object
  extended bycom.limegroup.gnutella.UDPService
All Implemented Interfaces:
java.lang.Runnable

public final class UDPService
extends java.lang.Object
implements java.lang.Runnable

This class handles UDP messaging services. It both sends and receives messages, routing received messages to their appropriate handlers. This also handles issues related to the GUESS proposal, such as making sure that the UDP and TCP port match and sending UDP acks for queries.

See Also:
UDPReplyHandler, MessageRouter, QueryUnicaster

Method Summary
 boolean canReceiveSolicited()
          Returns whether or not this node is capable of receiving SOLICITED UDP packets.
 boolean canReceiveUnsolicited()
          Returns whether or not this node is capable of receiving UNSOLICITED UDP packets.
 GUID getConnectBackGUID()
           
static UDPService instance()
          Instance accessor.
 boolean isGUESSCapable()
          Returns whether or not this node is capable of sending its own GUESS queries.
 boolean isListening()
          Returns whether or not the UDP socket is listening for incoming messsages.
 void run()
          Busy loop that accepts incoming messages sent over UDP and dispatches them to their appropriate handlers.
 void send(Message msg, java.net.InetAddress ip, int port)
          Sends the Message via UDP to the port and IP address specified.
 void start()
          Starts the UDP Service.
 java.lang.String toString()
          Overrides Object.toString to give more informative information about the class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

instance

public static UDPService instance()
Instance accessor.


start

public void start()
Starts the UDP Service.


getConnectBackGUID

public GUID getConnectBackGUID()
Returns:
The GUID to send for UDPConnectBack attempts....

run

public void run()
Busy loop that accepts incoming messages sent over UDP and dispatches them to their appropriate handlers.

Specified by:
run in interface java.lang.Runnable

send

public void send(Message msg,
                 java.net.InetAddress ip,
                 int port)
          throws java.io.IOException
Sends the Message via UDP to the port and IP address specified. This method should not be called if the client is not GUESS enabled. If sending fails for reasons such as a BindException, NoRouteToHostException or specific IOExceptions such as "No buffer space available", this message is silently dropped.

Parameters:
msg - the Message to send
ip - the InetAddress to send to
port - the port to send to
Throws:
java.io.IOException

isGUESSCapable

public boolean isGUESSCapable()
Returns whether or not this node is capable of sending its own GUESS queries. This would not be the case only if this node has not successfully received an incoming UDP packet.

Returns:
true if this node is capable of running its own GUESS queries, false otherwise

canReceiveUnsolicited

public boolean canReceiveUnsolicited()
Returns whether or not this node is capable of receiving UNSOLICITED UDP packets. It is false until a UDP ConnectBack ping has been received.

Returns:
true if this node has accepted a UNSOLICITED UDP packet.

canReceiveSolicited

public boolean canReceiveSolicited()
Returns whether or not this node is capable of receiving SOLICITED UDP packets.

Returns:
true if this node has accepted a SOLICITED UDP packet.

isListening

public boolean isListening()
Returns whether or not the UDP socket is listening for incoming messsages.

Returns:
true if the UDP socket is listening for incoming UDP messages, false otherwise

toString

public java.lang.String toString()
Overrides Object.toString to give more informative information about the class.

Returns:
the DatagramSocket data