package com.eactive.eai.common.session; 

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.rmi.server.RMISocketFactory;

/** 
* 1. 기능 : RMISocketFactory를 상속받아서 
*         connection Timeout 과 read Timeout 을 설정할수 있도록 구현
* 2. 처리 개요 : 
* 3. 주의사항 
*
* @author  : 
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since   : 
*  : 
*/
public class TimeoutRMISocketFactory extends RMISocketFactory
{ 
	private int connectionTimeout;
	private int readTimeout;
	public TimeoutRMISocketFactory(int connectionTimeout,int readTimeout){
		super();
		this.connectionTimeout = connectionTimeout;
		this.readTimeout =readTimeout;
	}
	public Socket createSocket(String host,int port) throws IOException{
		Socket socket = new Socket();
		socket.setSoTimeout(this.readTimeout);
		socket.setSoLinger(false, 0);
		socket.connect(new InetSocketAddress(host,port), this.connectionTimeout);
		return socket;
	}
	public ServerSocket createServerSocket(int port) throws IOException{
		return new ServerSocket(port);
	}
} 
