package org.kne.cloud.network.klalb;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;

import org.kne.cloud.network.DatagramSocketFactory;

public class KLALBVirtualDatagramSocketFactory extends DatagramSocketFactory {
	private KLALBController controller;

	public  KLALBVirtualDatagramSocketFactory(KLALBController controller) {
	this.controller=controller;	
	}
	
	public KLALBController getController() {
		return controller;
	}


	@Override
	public DatagramSocket createSocket() throws IOException {
		return new KLALBVirtualDatagramSocket(controller,null);
	}

	@Override
	public DatagramSocket createSocket(String paramString, int paramInt) throws IOException, UnknownHostException {
		DatagramSocket dg=new KLALBVirtualDatagramSocket(controller);
		dg.connect(new InetSocketAddress(paramString, paramInt));
		return dg;
	}

	@Override
	public DatagramSocket createSocket(InetAddress paramInetAddress, int paramInt) throws IOException {
		DatagramSocket dg=new KLALBVirtualDatagramSocket(controller);
		dg.connect(paramInetAddress, paramInt);
		return dg;
	}

	@Override
	public DatagramSocket createSocket(String paramString, int paramInt1, InetAddress paramInetAddress, int paramInt2)
			throws IOException, UnknownHostException {
		DatagramSocket dg=new KLALBVirtualDatagramSocket(controller,new InetSocketAddress(paramInetAddress, paramInt2));
		dg.connect(new InetSocketAddress(paramString, paramInt1));
		return dg;
	}

	@Override
	public DatagramSocket createSocket(InetAddress paramInetAddress1, int paramInt1, InetAddress paramInetAddress2,
			int paramInt2) throws IOException {
		DatagramSocket dg=new KLALBVirtualDatagramSocket(controller,new InetSocketAddress(paramInetAddress2, paramInt2));
		dg.connect(paramInetAddress1, paramInt1);
		return dg;
	}

}
