Code example for Selector

Methods: wakeup

0
	} 
 
	//Aborts the select and the server 
	public void abort() throws IOException{ 
		this.server_aborted=true;
		this.server_selector.wakeup();
	} 
 
	//Initializes everything 
	public void initialize_selector_socketchannel() throws IOException{ 
		Log.d("TCPServerTask","Initializing selector and socketchannel");
		//Create selector and socketchannel 
		this.server_selector=SelectorProvider.provider().openSelector();
		this.server_selectable_channel=ServerSocketChannel.open();
		//Set to non-blocking 
		this.server_selectable_channel.configureBlocking(false);
		//All access granted on port 
		InetSocketAddress bind_port=new InetSocketAddress(this.server_port);
		this.server_selectable_channel.socket().bind(bind_port);
		//Initializing buffer 
		this.server_read_buffer=ByteBuffer.allocate(NachosConstants.READ_BUFFER_SIZE);