Any hints?
Code bellow:
- if I disconnect a device and plug in within the 100 seconds (simulating that it's looking for a device on www) it does not find it to ping it, it reports not ok. I did plug it back in real quick, it should have found it. - it waits for 1st "connect" to finish before trying the next. I will have 500 connections "testers" going on.

tia,
.V



netsql wrote:

can you post the code that is calling this?




class 1:
public class Start {
public static void main(String[] args) throws Exception {
    System.out.println("runing");
ArrayList lst = new ArrayList();
    Map row = new HashMap();
    row.put("ip","192.168.100.69");
    row.put("port",5001);

    connect(row);
    lst.add(row);
    row.put("ip","127.0.0.1");
    row.put("port",80);

    connect(row);
    lst.add(row);

    } //method
public static void connect(Map arow) {
        String ip = (String) arow.get("ip");
        int port = (Integer) arow.get("port");
Pinger p = new Pinger();
        p.ping( ip, port );
    }// connect


}// class


class 2:
public class Pinger {

    private final IoConnector _mConnector;
    private final IoHandler   _mHndlr= new IoHandlerAdapter();
    public Pinger() {
        _mConnector = new SocketConnector();
_mConnector.getDefaultConfig().setThreadModel( new PooledThreadModel("client", 200)); //xxx: 500 a time?? ((IoConnectorConfig) _mConnector.getDefaultConfig()).setConnectTimeout(100); // 30 seconds
    }

    public void ping(String aip, int aport) {
ConnectFuture future= _mConnector.connect(new InetSocketAddress(aip,aport), _mHndlr);

        future.join();

        try {
           future.getSession(); // have session?
//XX bug here - if I unplug device for 10 seconds and then plug in, it reports not ok - but should find. //also, if one ping is taking a long time, it does not go on to next.
           System.out.println("OK"+aport);
        } catch (Exception e) {
           System.out.println("NOT_OK"+aport);
           //e.printStackTrace();
        }//try

    }//()
}//class


tia,
.V



Reply via email to