diff --git a/bindings/java/src/net/hyperic/sigar/Sigar.java b/bindings/java/src/net/hyperic/sigar/Sigar.java index 0b14e4a6..78e1f885 100644 --- a/bindings/java/src/net/hyperic/sigar/Sigar.java +++ b/bindings/java/src/net/hyperic/sigar/Sigar.java @@ -637,6 +637,46 @@ public class Sigar implements SigarProxy { public native NetConnection[] getNetConnectionList(int flags) throws SigarException; + /** + * Get the TCP listen address for the given port. + * If the port is not bound to a specific address, + * the loopback address will be returned. + * If there is not a listener on the given port, null will be returned. + */ + public String getNetListenAddress(long port) + throws SigarException { + + int flags = NetFlags.CONN_SERVER | NetFlags.CONN_TCP; + + NetConnection[] connections = + getNetConnectionList(flags); + + for (int i=0; i