package org.kne.cloud.network;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;

public class ProtocolDetectorServerSocketFactory extends DefaultServerSocketFactory {
	private ProtocolDetector pd;
	
	public ProtocolDetectorServerSocketFactory() {
		super();
		pd=ProtocolDetector.getNewDefaultDetector();
	}

	public ProtocolDetectorServerSocketFactory(ProtocolDetector pd) {
		super();
		this.pd = pd;
	}

	@Override
	public ServerSocket createServerSocket() throws IOException {
		return new ProtocolDetectorServerSocket(super.createServerSocket());
	}

	@Override
	public ServerSocket createServerSocket(int port) throws IOException {
		return new ProtocolDetectorServerSocket( super.createServerSocket(port),pd);
	}

	public ProtocolDetector getPd() {
		return pd;
	}

	public void setPd(ProtocolDetector pd) {
		this.pd = pd;
	}

	@Override
	public ServerSocket createServerSocket(int port, int backlog) throws IOException {
		return new ProtocolDetectorServerSocket(super.createServerSocket(port, backlog),pd);
	}

	@Override
	public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException {
		return new ProtocolDetectorServerSocket(super.createServerSocket(port, backlog, ifAddress),pd);
	}

}
