Examples of NetStatObject


Examples of systeminformationmonitor.system.object.NetStatObject

            Logger.getLogger(NetStat.class.getName()).log(Level.SEVERE, null, ex);
        }

        for (int i = 0; i < connections.length; i++) {
            NetConnection conn = connections[i];
            NetStatObject netObj = new NetStatObject();

            String proto = conn.getTypeString();
            String state;
            if (conn.getType() == NetFlags.CONN_UDP) {
                state = "";
            } else {
                state = conn.getStateString();
            }


            netObj.setType(proto);
            netObj.setLocalAddress(formatAddress(conn.getType(),
                    conn.getLocalAddress(),
                    conn.getLocalPort(),
                    LADDR_LEN));
            netObj.setRemoteAddress(formatAddress(conn.getType(),
                    conn.getRemoteAddress(),
                    conn.getRemotePort(),
                    RADDR_LEN));
            netObj.setState(state);

            String process = null;
            if (wantPid &&
                    //XXX only works w/ listen ports
                    (conn.getState() == NetFlags.TCP_LISTEN)) {
                try {
                    long pid =
                            sigar.getProcPort(conn.getType(),
                            conn.getLocalPort());
                    if (pid != 0) { //XXX another bug
                        String name =
                                sigar.getProcState(pid).getName();
                        process = pid + "/" + name;
                    }
                } catch (SigarException e) {
                }
            }

            if (process == null) {
                process = "";
            }

            netObj.setProcess(process);

            netVector.add(netObj);
        }       
        return netVector;
    }
View Full Code Here

Examples of systeminformationmonitor.system.object.NetStatObject

        return columnNames[column];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        NetStatObject temp = rowData.get(rowIndex);
        switch(columnIndex){
            case 0: return temp.getType();
            case 1: return temp.getLocalAddress();
            case 2: return temp.getRemoteAddress();
            case 3: return temp.getState();
            case 4: return temp.getProcess();
            default: return "";
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.