FileDocCategorySizeDatePackage
VirtualAcceptSelector.javaAPI DocAzureus 3.0.3.43525Tue Oct 31 18:59:30 GMT 2006com.aelitis.azureus.core.networkmanager.impl.tcp

VirtualAcceptSelector

public class VirtualAcceptSelector extends Object
Virtual server socket channel for listening and accepting incoming connections.

Fields Summary
private static final VirtualAcceptSelector
singleton
private static final LogIDs
LOGID
private final com.aelitis.azureus.core.networkmanager.VirtualChannelSelector
accept_selector
Constructors Summary
protected VirtualAcceptSelector()


	
	
	
		AEThread select_thread = new AEThread( "Accept Selector" ) {
			public void 
			runSupport() 
			{
				while( true ) {
	        	
					try{
						accept_selector.select( 50 );
	           
					}catch( Throwable e ){
	    			  
						Debug.printStackTrace(e);
					}
				}
			}
	    };
	    
	    select_thread.setDaemon( true );
	    select_thread.start();
	
Methods Summary
public voidcancel(java.nio.channels.ServerSocketChannel channel)

		accept_selector.cancel( channel );
	
public static com.aelitis.azureus.core.networkmanager.impl.tcp.VirtualAcceptSelectorgetSingleton()

	
	  
	
	
		return( singleton );
	
public voidregister(java.nio.channels.ServerSocketChannel channel, com.aelitis.azureus.core.networkmanager.impl.tcp.VirtualAcceptSelector$AcceptListener listener)

		accept_selector.register( 
			channel,
			new VirtualChannelSelector.VirtualAcceptSelectorListener()
			{
				public boolean 
				selectSuccess(
					VirtualChannelSelector 	selector, 
					ServerSocketChannel 	sc, 
					Object 					attachment)
				{
					try{
						SocketChannel	new_channel = sc.accept();
					
						if ( new_channel == null ){
						
							return( false );
						}
					
						new_channel.configureBlocking( false );
						
						listener.newConnectionAccepted( new_channel );
						
						return( true );
						
					}catch( IOException e ){
						
						Debug.printStackTrace(e);
						
						return( true );
					}
				}
				 
				public void 
				selectFailure(
					VirtualChannelSelector 	selector, 
					ServerSocketChannel 	sc, 
					Object 					attachment, 
					Throwable 				msg )
				{
					Debug.printStackTrace(msg);
				}
			},
			null );