diff options
Diffstat (limited to 'java/com/tigervnc/network')
-rw-r--r-- | java/com/tigervnc/network/Socket.java | 1 | ||||
-rw-r--r-- | java/com/tigervnc/network/TcpSocket.java | 15 |
2 files changed, 12 insertions, 4 deletions
diff --git a/java/com/tigervnc/network/Socket.java b/java/com/tigervnc/network/Socket.java index bc0af5cb..0fadad4a 100644 --- a/java/com/tigervnc/network/Socket.java +++ b/java/com/tigervnc/network/Socket.java @@ -51,6 +51,7 @@ abstract public class Socket { // information about the remote end of the socket abstract public String getPeerAddress(); // a string e.g. "192.168.0.1" + abstract public String getPeerName(); abstract public int getPeerPort(); abstract public String getPeerEndpoint(); // <address>::<port> diff --git a/java/com/tigervnc/network/TcpSocket.java b/java/com/tigervnc/network/TcpSocket.java index 9672fe5e..c4c1a8cf 100644 --- a/java/com/tigervnc/network/TcpSocket.java +++ b/java/com/tigervnc/network/TcpSocket.java @@ -118,15 +118,22 @@ public class TcpSocket extends Socket { } public String getPeerAddress() { - SocketAddress peer = ((SocketDescriptor)getFd()).socket().getRemoteSocketAddress(); + InetAddress peer = ((SocketDescriptor)getFd()).socket().getInetAddress(); if (peer != null) - return peer.toString(); + return peer.getHostAddress(); + return ""; + } + + public String getPeerName() { + InetAddress peer = ((SocketDescriptor)getFd()).socket().getInetAddress(); + if (peer != null) + return peer.getHostName(); return ""; } public int getPeerPort() { - SocketAddress address = ((SocketDescriptor)getFd()).socket().getRemoteSocketAddress(); - return ((InetSocketAddress)address).getPort(); + int port = ((SocketDescriptor)getFd()).socket().getPort(); + return port; } public String getPeerEndpoint() { |