Package org.quickserver.net.client

Examples of org.quickserver.net.client.BlockingClient


  private SSLSocketFactory sslSocketFactory;
 

  public char monitor(Host host) {   
    SocketBasedHost socketBasedHost = (SocketBasedHost) host;
    BlockingClient client = new BlockingClient();
    try {   
      client.setSecure(socketBasedHost.isSecure());
      client.setUseDummyTrustManager(isUseDummyTrustManager());
     
      if(getSslSocketFactory()!=null) {
        client.setSslSocketFactory(getSslSocketFactory());
      }
     
      client.connect(socketBasedHost.getInetAddress().getHostAddress(),
          socketBasedHost.getInetSocketAddress().getPort());
     
      if(socketBasedHost.getTextToExpect()!=null) {
        String textGot = client.readBytes();
        if(textGot.indexOf(socketBasedHost.getTextToExpect())!=-1) {
          return Host.ACTIVE;
        } else {
          logger.fine(socketBasedHost+" Error: Text ["+socketBasedHost.getTextToExpect()
              +"]Not found! Got: "+textGot);
          return Host.DOWN;
        }
      } else {     
        return Host.ACTIVE;
      }
    } catch (IOException e) {
      logger.fine(socketBasedHost+" IOError: "+e);
      return Host.DOWN;
    } catch (Exception e) {
      logger.warning(socketBasedHost+" Error: "+e);
      return Host.ERROR;
    } finally {
      if(client!=null) {
        try {
          client.close();
        } catch (IOException ex) {
          Logger.getLogger(SocketMonitor.class.getName()).log(Level.FINE, "Error", ex);
        }
      }
      host.setLastCheckedOn(new Date());
View Full Code Here

TOP

Related Classes of org.quickserver.net.client.BlockingClient

Copyright © 2018 www.massapicom. 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.