view rep/channel/ServerChannelSimulator.java @ 162:2bd3264abf55

*** empty log message ***
author pin
date Thu, 28 Aug 2008 16:54:54 +0900
parents 31334767e65d
children 9bb6bbb08ad7
line wrap: on
line source

package rep.channel;

import java.io.IOException;
import java.net.ServerSocket;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;

public class ServerChannelSimulator<P>extends REPServerSocketChannel<P>{
	protected NetworkSimulator<P> ns;
	public REPServerSocket<REPSocketChannel<P>> socket;

	/**  Constructors. 
	 * @throws IOException */
	public ServerChannelSimulator() throws IOException {
		socket = REPServerSocket.<REPSocketChannel<P>>create();
	}

	public REPSocketChannel<P> accept1() throws IOException {
		return new REPSocketChannel<P>(ss.accept());
	}

	@Override
	public ServerSocket socket() {
		return socket;
	}

	@Override
	protected void implCloseSelectableChannel() throws IOException {
		ss.close();
	}

	@Override
	protected void implConfigureBlocking(boolean block) throws IOException {
		ss.configureBlocking(block);
	}

	@Override
	public SocketChannel accept() throws IOException {
		// TODO Auto-generated method stub
		return null;
	}
	

	public SelectionKey register(REPSelector sel, int ops, Object att) throws ClosedChannelException {
		REPSelector selector = sel;
		return selector.register(this, ops, att);
	}

}