package org.kne.cloud.network;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.channels.SocketChannel;

public class DefaultSocketChannelFactory extends SocketChannelFactory {
	
	@Override
	public SocketChannel createSocketChannel() throws IOException {
		return SocketChannel.open();
	}

	@Override
	public SocketChannel createSocketChannel(String paramString, int paramInt) throws IOException {
		SocketChannel conn=createSocketChannel();
		conn.connect(new InetSocketAddress(paramString, paramInt));
		return conn;
	}

	@Override
	public SocketChannel createSocketChannel(InetAddress paramInetAddress, int paramInt) throws IOException {
		SocketChannel conn=createSocketChannel();
		conn.connect(new InetSocketAddress(paramInetAddress, paramInt));
		return conn;
	}

	@Override
	public SocketChannel createSocketChannel(String paramString, int paramInt1, InetAddress paramInetAddress,
			int paramInt2) throws IOException, UnknownHostException {
		SocketChannel conn=createSocketChannel();
		conn.bind(new InetSocketAddress(paramInetAddress, paramInt2));
		conn.connect(new InetSocketAddress(paramString, paramInt1));
		return conn;
	}

	@Override
	public SocketChannel createSocketChannel(InetAddress paramInetAddress1, int paramInt1,
			InetAddress paramInetAddress2, int paramInt2) throws IOException {
		SocketChannel conn=createSocketChannel();
		conn.bind(new InetSocketAddress(paramInetAddress2, paramInt2));
		conn.connect(new InetSocketAddress(paramInetAddress1, paramInt1));
		return conn;
	}

}
