|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.tomp2p.peers.PeerAddress
public final class PeerAddress
A PeerAddress contains the node ID and how to contact this node using both TCP and UDP. This class is thread safe (or it does not matter if its not). The serialized size of this class is for IPv4 (20 + 4 + 1 + 4=29), for IPv6 (20 + 4 + 1 + 16=41)
| Field Summary | |
|---|---|
static int |
SIZE_IP_SOCKv4
|
static int |
SIZE_IP_SOCKv6
|
static int |
SIZE_IPv4
|
static int |
SIZE_IPv6
|
| Constructor Summary | |
|---|---|
PeerAddress(byte[] me)
Creates a new peeraddress, where the byte array has to be in the rigth format and in the rigth size. |
|
PeerAddress(byte[] me,
int offset)
Creates a PeerAddress from a continuous byte array. |
|
PeerAddress(Number160 id)
This is usually used for debugging, the address will be null and ports -1 |
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP)
|
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
boolean forwarded,
boolean firewalledUDP,
boolean firewalledTCP)
Creates a PeerAddress |
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
byte optionType)
|
|
PeerAddress(Number160 id,
InetSocketAddress inetSocketAddress)
|
|
PeerAddress(Number160 id,
PeerAddress parent)
|
|
| Method Summary | |
|---|---|
int |
compareTo(PeerAddress nodeAddress)
|
PeerAddress |
copyWithDifferentId(Number160 id2)
|
InetSocketAddress |
createSocketTCP()
Returns the socket address. |
InetSocketAddress |
createSocketUDP()
Returns the socket address. |
byte |
createType()
|
boolean |
equals(Object obj)
|
static int |
expectedLength(int type)
|
PeerAddress |
forward(InetAddress inetAddress)
|
Number160 |
getID()
The id of the peer. |
InetAddress |
getInetAddress()
Returns the address or null if no address set |
byte[] |
getSocketAddress()
|
int |
getSocketAddress(byte[] me,
int offset)
|
int |
getSocketAddressSize()
|
int |
hashCode()
|
boolean |
isFirewalledTCP()
|
static boolean |
isFirewalledTCP(int type)
|
boolean |
isFirewalledUDP()
|
static boolean |
isFirewalledUDP(int type)
|
static boolean |
isForward(int type)
|
boolean |
isForwarded()
|
boolean |
isIPv6()
|
static boolean |
isNet6(int type)
|
PeerAddress |
notFirewalledTCP()
|
PeerAddress |
notFirewalledUDP()
|
int |
offset()
When deserializeg, we need to know how much we deserialized from the constructor call. |
PeerAddress |
ports(int portUDP,
int portTCP)
|
int |
portTCP()
|
int |
portUDP()
|
byte[] |
toByteArray()
Serializes to a new array with the proper size |
int |
toByteArray(byte[] me,
int offset)
Serializes to an existing array. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int SIZE_IP_SOCKv6
public static final int SIZE_IP_SOCKv4
public static final int SIZE_IPv6
public static final int SIZE_IPv4
| Constructor Detail |
|---|
public PeerAddress(byte[] me)
throws UnknownHostException
me - The serialized array
UnknownHostException - Using InetXAddress.getByAddress creates this
exception.
public PeerAddress(byte[] me,
int offset)
throws UnknownHostException
me - The serialized arrayoffset - the offset, where to start
UnknownHostException - Using InetXAddress.getByAddress creates this
exception.public PeerAddress(Number160 id)
id - The id of the peer
public PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
boolean forwarded,
boolean firewalledUDP,
boolean firewalledTCP)
id - The id of the peeraddress - The address of the peer, how to reach this peerportTCP - The tcp port how to reach the peerportUDP - The udp port how to reach the peer
public PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP)
public PeerAddress(Number160 id,
InetSocketAddress inetSocketAddress)
public PeerAddress(Number160 id,
PeerAddress parent)
public PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
byte optionType)
| Method Detail |
|---|
public int offset()
public byte[] toByteArray()
public int toByteArray(byte[] me,
int offset)
me - The array where the result should be storedoffset - The offset where to start to save the result in the byte
array
public byte[] getSocketAddress()
public int getSocketAddress(byte[] me,
int offset)
public InetAddress getInetAddress()
public InetSocketAddress createSocketTCP()
public InetSocketAddress createSocketUDP()
public Number160 getID()
public byte createType()
public static boolean isNet6(int type)
public static boolean isForward(int type)
public static boolean isFirewalledTCP(int type)
public static boolean isFirewalledUDP(int type)
public static int expectedLength(int type)
public String toString()
toString in class Objectpublic int compareTo(PeerAddress nodeAddress)
compareTo in interface Comparable<PeerAddress>public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic int portTCP()
public int portUDP()
public boolean isForwarded()
public boolean isFirewalledUDP()
public boolean isFirewalledTCP()
public boolean isIPv6()
public PeerAddress notFirewalledUDP()
public PeerAddress notFirewalledTCP()
public PeerAddress forward(InetAddress inetAddress)
public PeerAddress ports(int portUDP,
int portTCP)
public int getSocketAddressSize()
public PeerAddress copyWithDifferentId(Number160 id2)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||