diff --git a/bindings/java/src/net/hyperic/sigar/Sigar.java b/bindings/java/src/net/hyperic/sigar/Sigar.java index 78e1f885..cc7cfaea 100644 --- a/bindings/java/src/net/hyperic/sigar/Sigar.java +++ b/bindings/java/src/net/hyperic/sigar/Sigar.java @@ -659,11 +659,17 @@ public class Sigar implements SigarProxy { } if (conn.getLocalPort() == port) { - if (conn.getLocalAddress().equals(NetFlags.ANY_ADDR)) { + String address = + conn.getLocalAddress(); + + if (address.equals(NetFlags.ANY_ADDR)) { return NetFlags.LOOPBACK_ADDRESS; } + else if (address.equals(NetFlags.ANY_ADDR_V6)) { + return NetFlags.LOOPBACK_ADDRESS_V6; + } else { - return conn.getLocalAddress(); + return address; } } } diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java b/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java index 54f8da7b..e16d8c6e 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java @@ -110,12 +110,12 @@ public class Netstat extends SigarCommandBase { String port = formatPort(proto, portnum); String address; - if (isNumeric) { - address = ip; - } - else if (ip.equals(NetFlags.ANY_ADDR)) { + if (NetFlags.isAnyAddress(ip)) { address = "*"; } + else if (isNumeric) { + address = ip; + } else { try { address = InetAddress.getByName(ip).getHostName();