|
||||||||||
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 PeerAddress |
EMPTY_IPv4
|
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 right size. |
|
PeerAddress(byte[] peerAddress,
byte[] socketAddress)
The format of the peer address can also be split. |
|
PeerAddress(byte[] me,
int offset)
Creates a PeerAddress from a continuous byte array. |
|
PeerAddress(Number160 id)
If you only need to know the id |
|
PeerAddress(Number160 id,
byte[] me,
int offset)
|
|
PeerAddress(Number160 id,
org.jboss.netty.buffer.ChannelBuffer channelBuffer)
|
|
PeerAddress(Number160 id,
InetAddress address)
If you only need to know the id and InetAddress |
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP)
|
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
boolean firewalledUDP,
boolean firewalledTCP)
Creates a PeerAddress |
|
PeerAddress(Number160 id,
InetAddress address,
int portTCP,
int portUDP,
int options)
|
|
PeerAddress(Number160 id,
InetSocketAddress inetSocketAddress)
|
|
PeerAddress(Number160 id,
PeerAddress parent)
|
|
PeerAddress(Number160 id,
String address,
int portTCP,
int portUDP)
|
Method Summary | |
---|---|
PeerAddress |
changeAddress(InetAddress address)
|
PeerAddress |
changeFirewalledTCP(boolean status)
|
PeerAddress |
changeFirewalledUDP(boolean status)
|
PeerAddress |
changePeerId(Number160 id2)
|
PeerAddress |
changePorts(int portUDP,
int portTCP)
|
int |
compareTo(PeerAddress nodeAddress)
|
InetSocketAddress |
createSocketTCP()
Returns the socket address. |
InetSocketAddress |
createSocketUDP()
Returns the socket address. |
boolean |
equals(Object obj)
|
int |
expectedLength()
|
static int |
expectedLength(int options)
|
static int |
expectedSocketLength(int options)
|
Number160 |
getID()
The id of the peer. |
InetAddress |
getInetAddress()
Returns the address or null if no address set |
byte |
getOptions()
|
int |
getSocketAddressSize()
|
int |
hashCode()
|
boolean |
isFirewalledTCP()
|
static boolean |
isFirewalledTCP(int options)
|
boolean |
isFirewalledUDP()
|
static boolean |
isFirewalledUDP(int options)
|
boolean |
isIPv4()
|
boolean |
isIPv6()
|
static boolean |
isNet6(int options)
|
int |
offset()
When deserializing, we need to know how much we deserialized from the constructor call. |
int |
portTCP()
|
int |
portUDP()
|
int |
readBytes()
|
byte[] |
toByteArray()
Serializes to a new array with the proper size |
int |
toByteArray(byte[] me,
int offset)
Serializes to an existing array. |
byte[] |
toByteArraySocketAddress()
|
int |
toByteArraySocketAddress(byte[] me,
int offset)
|
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
public static final PeerAddress EMPTY_IPv4
Constructor Detail |
---|
public PeerAddress(byte[] me)
me
- The serialized array
UnknownHostException
- Using InetXAddress.getByAddress creates this exception.public PeerAddress(byte[] me, int offset)
me
- The serialized arrayoffset
- the offset, where to start
UnknownHostException
- Using InetXAddress.getByAddress creates this exception.public PeerAddress(Number160 id, org.jboss.netty.buffer.ChannelBuffer channelBuffer)
public PeerAddress(Number160 id, byte[] me, int offset)
public PeerAddress(byte[] peerAddress, byte[] socketAddress)
peerAddress
- The 160bit number for the peer IDsocketAddress
- The socket address with type port and IP
UnknownHostException
public PeerAddress(Number160 id)
id
- The id of the peerpublic PeerAddress(Number160 id, InetAddress address)
id
- The id of the peeraddress
- The InetAddress of the peerpublic PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP, 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 peerpublic PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP)
public PeerAddress(Number160 id, String address, int portTCP, int portUDP) throws UnknownHostException
UnknownHostException
public PeerAddress(Number160 id, InetSocketAddress inetSocketAddress)
public PeerAddress(Number160 id, PeerAddress parent)
public PeerAddress(Number160 id, InetAddress address, int portTCP, int portUDP, int options)
Method Detail |
---|
public int offset()
public int readBytes()
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[] toByteArraySocketAddress()
public int toByteArraySocketAddress(byte[] me, int offset)
public InetAddress getInetAddress()
public InetSocketAddress createSocketTCP()
public InetSocketAddress createSocketUDP()
public Number160 getID()
public byte getOptions()
public static boolean isNet6(int options)
public static boolean isFirewalledTCP(int options)
public static boolean isFirewalledUDP(int options)
public static int expectedLength(int options)
public static int expectedSocketLength(int options)
public int expectedLength()
public String toString()
toString
in class Object
public int compareTo(PeerAddress nodeAddress)
compareTo
in interface Comparable<PeerAddress>
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int portTCP()
public int portUDP()
public boolean isFirewalledUDP()
public boolean isFirewalledTCP()
public boolean isIPv6()
public boolean isIPv4()
public PeerAddress changeFirewalledUDP(boolean status)
public PeerAddress changeFirewalledTCP(boolean status)
public PeerAddress changePorts(int portUDP, int portTCP)
public PeerAddress changeAddress(InetAddress address)
public PeerAddress changePeerId(Number160 id2)
public int getSocketAddressSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |