com.limegroup.gnutella.messages
Class QueryReply.IPPortCombo

java.lang.Object
  extended bycom.limegroup.gnutella.messages.QueryReply.IPPortCombo
Enclosing class:
QueryReply

public static class QueryReply.IPPortCombo
extends java.lang.Object

Another utility class the encapsulates some complexity. Keep in mind that I very well could have used Endpoint here, but I decided against it mainly so I could do validity checking. This may be a bad decision. I'm sure someone will let me know during code review.


Field Summary
static java.lang.String DELIM
           
 
Constructor Summary
QueryReply.IPPortCombo(java.lang.String hostAddress, int port)
          Constructor used for local data.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.net.InetAddress getAddress()
           
static QueryReply.IPPortCombo getCombo(byte[] fromNetwork)
          Used for reading data from the network.
 int getPort()
           
 int hashCode()
           
 byte[] toBytes()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIM

public static final java.lang.String DELIM
See Also:
Constant Field Values
Constructor Detail

QueryReply.IPPortCombo

public QueryReply.IPPortCombo(java.lang.String hostAddress,
                              int port)
                       throws java.net.UnknownHostException,
                              java.lang.IllegalArgumentException
Constructor used for local data. Throws IllegalArgumentException on errors.

Method Detail

getCombo

public static QueryReply.IPPortCombo getCombo(byte[] fromNetwork)
                                       throws BadPacketException
Used for reading data from the network. Throws BadPacketException if the data is invalid.

Parameters:
fromNetwork - 6 bytes - first 4 are IP, next 2 are port
Throws:
BadPacketException

getPort

public int getPort()

getAddress

public java.net.InetAddress getAddress()

toBytes

public byte[] toBytes()
Returns:
the ip and port encoded in 6 bytes (4 ip, 2 port). //TODO if IPv6 kicks in, this may fail, don't worry so much now.

equals

public boolean equals(java.lang.Object other)

hashCode

public int hashCode()