package org.kne.cloud.network;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketImpl;
import java.nio.channels.ServerSocketChannel;
import java.util.function.Function;

public class FilterServerSocket extends ServerSocket {
	private ServerSocket serversocket;
	public FilterServerSocket(ServerSocket serversocket)throws IOException {
		this.serversocket=serversocket;
	}
	@Override
	public void bind(SocketAddress endpoint) throws IOException {
		serversocket.bind(endpoint);
	}
	@Override
	public void bind(SocketAddress endpoint, int backlog) throws IOException {
		serversocket.bind(endpoint, backlog);
	}
	@Override
	public InetAddress getInetAddress() {
		return serversocket.getInetAddress();
	}
	@Override
	public int getLocalPort() {
		return serversocket.getLocalPort();
	}
	@Override
	public SocketAddress getLocalSocketAddress() {
		return serversocket.getLocalSocketAddress();
	}
	@Override
	public FilterSocket accept() throws IOException {
		return socketFilterFunction(  serversocket.accept());
	}
	protected FilterSocket socketFilterFunction(Socket accept) {
		return new FilterSocket(accept);
	}
	@Override
	public void close() throws IOException {
		serversocket.close();
	}
	@Override
	public ServerSocketChannel getChannel() {
		return serversocket.getChannel();
	}
	@Override
	public boolean isBound() {
		return serversocket.isBound();
	}
	@Override
	public boolean isClosed() {
		return serversocket.isClosed();
	}
	@Override
	public synchronized void setSoTimeout(int timeout) throws SocketException {
		// TODO 自动生成的方法存根
		serversocket.setSoTimeout(timeout);
	}
	@Override
	public synchronized int getSoTimeout() throws IOException {
		// TODO 自动生成的方法存根
		return serversocket.getSoTimeout();
	}
	@Override
	public void setReuseAddress(boolean on) throws SocketException {
		// TODO 自动生成的方法存根
		serversocket.setReuseAddress(on);
	}
	@Override
	public boolean getReuseAddress() throws SocketException {
		// TODO 自动生成的方法存根
		return serversocket.getReuseAddress();
	}
	@Override
	public String toString() {
		// TODO 自动生成的方法存根
		return serversocket.toString();
	}
	@Override
	public synchronized void setReceiveBufferSize(int size) throws SocketException {
		// TODO 自动生成的方法存根
		serversocket.setReceiveBufferSize(size);
	}
	@Override
	public synchronized int getReceiveBufferSize() throws SocketException {
		// TODO 自动生成的方法存根
		return serversocket.getReceiveBufferSize();
	}
	@Override
	public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
		// TODO 自动生成的方法存根
		serversocket.setPerformancePreferences(connectionTime, latency, bandwidth);
	}

}
