From ca1e9686d91fb7f71d81a11d40bb0b955bb8fd82 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 11 Mar 2005 02:37:59 +0000 Subject: [PATCH] map port to service name --- .../java/src/net/hyperic/sigar/cmd/Netstat.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java b/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java index f0b9cea6..8e2ddb41 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Netstat.java @@ -6,6 +6,7 @@ import java.net.UnknownHostException; import net.hyperic.sigar.SigarException; import net.hyperic.sigar.NetConnection; import net.hyperic.sigar.NetFlags; +import net.hyperic.sigar.NetPortMap; /** * Display network connections. @@ -79,10 +80,16 @@ public class Netstat extends SigarCommandBase { return flags; } - private String formatPort(long port) { + private String formatPort(String proto, long port) { if (port == 0) { return "*"; } + if (!isNumeric) { + String service = NetPortMap.getServiceName(proto, port); + if (service != null) { + return service; + } + } return String.valueOf(port); } @@ -117,14 +124,14 @@ public class Netstat extends SigarCommandBase { for (int i=0; i