public class HostItem
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
hostname |
private java.net.InetAddress |
inetAddress |
private int |
port |
private java.net.Socket |
tcpSocket |
private java.net.DatagramSocket |
udpSocket |
Constructor and Description |
---|
HostItem(java.net.Socket s)
Constructor from Socket.
|
HostItem(java.lang.String hostname,
int port)
Constructor with hostname and port
|
Modifier and Type | Method and Description |
---|---|
void |
closeTCPSocket()
Closes tcp socket
|
void |
closeUDPSocket()
Closes udp socket
|
boolean |
equals(java.lang.Object other)
Override of equals method
|
java.lang.String |
getHostname()
Getter for hostname
|
java.net.InetAddress |
getInetAddress()
Get InetAddress associated to this HostItem.
|
int |
getPort()
Getter for port
|
java.net.Socket |
getTCPSocket()
Get TCP Socket.
|
java.net.DatagramSocket |
getUDPSocket()
Get UDP Socket
return UDP Socket
|
int |
hashCode()
Override of hashCode method
|
java.lang.String |
toString()
To string
|
java.net.Socket |
tryGetTCPSocket()
Get TCP Socket.
|
java.net.DatagramSocket |
tryGetUDPSocket()
Get UDP Socket.
|
private java.lang.String hostname
private int port
private java.net.Socket tcpSocket
private java.net.DatagramSocket udpSocket
private java.net.InetAddress inetAddress
public HostItem(java.lang.String hostname, int port)
hostname
- Hostnameport
- Portpublic HostItem(java.net.Socket s)
s
- socketpublic java.net.Socket getTCPSocket()
public java.net.Socket tryGetTCPSocket() throws java.net.SocketException, java.net.UnknownHostException, java.io.IOException
java.net.SocketException
java.net.UnknownHostException
java.io.IOException
public void closeTCPSocket()
public java.net.DatagramSocket getUDPSocket()
public java.net.DatagramSocket tryGetUDPSocket() throws java.net.SocketException, java.net.UnknownHostException
java.net.SocketException
java.net.UnknownHostException
public void closeUDPSocket()
public java.lang.String getHostname()
public int getPort()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- Object to test equality withpublic int hashCode()
hashCode
in class java.lang.Object
public java.net.InetAddress getInetAddress()