Package com.zhangwoo.spider.client.process

Source Code of com.zhangwoo.spider.client.process.TaskClientHandler

package com.zhangwoo.spider.client.process;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.core.session.IoSessionConfig;
import org.apache.mina.transport.socket.SocketSessionConfig;

public class TaskClientHandler extends IoHandlerAdapter {
  @Override
  public void sessionCreated(IoSession session) throws Exception {
    IoSessionConfig cfg = session.getConfig();
      if (cfg instanceof SocketSessionConfig) {
       ((SocketSessionConfig) cfg).setKeepAlive(false);
       ((SocketSessionConfig) cfg).setSoLinger(0);
       ((SocketSessionConfig) cfg).setTcpNoDelay(true);
       ((SocketSessionConfig) cfg).setWriteTimeout(1000 * 5);
      }
  }
}
TOP

Related Classes of com.zhangwoo.spider.client.process.TaskClientHandler

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.