本文整理汇总了Java中org.hyperic.sigar.NetFlags.CONN_TCP属性的典型用法代码示例。如果您正苦于以下问题:Java NetFlags.CONN_TCP属性的具体用法?Java NetFlags.CONN_TCP怎么用?Java NetFlags.CONN_TCP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.hyperic.sigar.NetFlags
的用法示例。
在下文中一共展示了NetFlags.CONN_TCP属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outputStats
private void outputStats(int flags) throws SigarException {
if ((flags & NetFlags.CONN_TCP) != 0) {
println("Tcp:");
try {
outputTcpStats();
} catch (SigarException e) {
println(" " + e);
}
}
}
示例2: getNetStats
public static List<JSON> getNetStats() throws SigarException {
_init();
int flags = NetFlags.CONN_CLIENT | NetFlags.CONN_SERVER | NetFlags.CONN_TCP | NetFlags.CONN_UDP
| NetFlags.CONN_PROTOCOLS;
NetConnection[] nn = sigar.getNetConnectionList(flags);
List<JSON> l1 = new ArrayList<JSON>();
for (NetConnection n : nn) {
if (n.getRemotePort() == 0 && n.getLocalPort() == 0)
continue;
JSON jo = JSON.create().append("remoteaddress", n.getRemoteAddress())
.append("remoteport", n.getRemotePort()).append("localaddress", n.getLocalAddress())
.append("localport", n.getLocalPort()).append("recvqueue", n.getReceiveQueue())
.append("sendqueue", n.getSendQueue()).append("state", n.getState()).append("type", n.getType())
.append("typename", n.getTypeString());
if (n.getType() != NetFlags.CONN_UDP) {
jo.append("statename", n.getStateString());
}
try {
long pid = sigar.getProcPort(n.getType(), n.getLocalPort());
if (pid != 0) {
ProcState p = sigar.getProcState(pid);
if (p != null) {
jo.append("pid", pid + "/" + p.getName());
}
}
} catch (Exception e) {
// ignore
log.warn("get pid error, type=" + n.getType() + ", port=" + n.getLocalPort());
}
l1.add(jo);
}
return l1;
}
示例3: getFlags
public static int getFlags(String[] args, int flags) {
int proto_flags = 0;
isNumeric = false;
wantPid = false;
isStat = false;
for (int i=0; i<args.length; i++) {
String arg = args[i];
int j = 0;
while (j<arg.length()) {
switch (arg.charAt(j++)) {
case '-':
continue;
case 'l':
flags &= ~NetFlags.CONN_CLIENT;
flags |= NetFlags.CONN_SERVER;
break;
case 'a':
flags |= NetFlags.CONN_SERVER | NetFlags.CONN_CLIENT;
break;
case 'n':
isNumeric = true;
break;
case 'p':
wantPid = true;
break;
case 's':
isStat = true;
break;
case 't':
proto_flags |= NetFlags.CONN_TCP;
break;
case 'u':
proto_flags |= NetFlags.CONN_UDP;
break;
case 'w':
proto_flags |= NetFlags.CONN_RAW;
break;
case 'x':
proto_flags |= NetFlags.CONN_UNIX;
break;
default:
System.err.println("unknown option");
}
}
}
if (proto_flags != 0) {
flags &= ~NetFlags.CONN_PROTOCOLS;
flags |= proto_flags;
}
return flags;
}