src/main/java/org/java_websocket/server/WebSocketServer.java
private void doAccept(SelectionKey key, Iterator<SelectionKey> i) throws IOException, InterruptedException {
		if( !onConnect( key ) ) {
			key.cancel();
			return;
		}

		SocketChannel channel = server.accept();
		if(channel==null){
			return;
		}
		channel.configureBlocking( false );
		Socket socket = channel.socket();
		socket.setTcpNoDelay( isTcpNoDelay() );
		socket.setKeepAlive( true );
		WebSocketImpl w = wsf.createWebSocket( this, drafts );
		w.setSelectionKey(channel.register( selector, SelectionKey.OP_READ, w ));
		try {
			w.setChannel( wsf.wrapChannel( channel, w.getSelectionKey() ));
			i.remove();
			allocateBuffers( w );
		} catch (IOException ex) {
			if( w.getSelectionKey() != null )
				w.getSelectionKey().cancel();

			handleIOException( w.getSelectionKey(), null, ex );
		}
	}
private void doAccept(SelectionKey key, Iterator<SelectionKey> i) throws IOException, InterruptedException {
		if( !onConnect( key ) ) {
			key.cancel();
			return;
		}

		SocketChannel channel = server.accept();
		if(channel==null){
			return;
		}
		channel.configureBlocking( false );
		Socket socket = channel.socket();
		socket.setTcpNoDelay( isTcpNoDelay() );
		socket.setKeepAlive( true );
		WebSocketImpl w = wsf.createWebSocket( this, drafts );
		w.setSelectionKey(channel.register( selector, SelectionKey.OP_READ, w ));
		try {
			w.setChannel( wsf.wrapChannel( channel, w.getSelectionKey() ));
			i.remove();
			allocateBuffers( w );
		} catch (IOException ex) {
			if( w.getSelectionKey() != null )
				w.getSelectionKey().cancel();

			handleIOException( w.getSelectionKey(), null, ex );
		}
	}
Execute a accept operation
@param key the selectionkey to read off
@param i the iterator for the selection keys
@throws InterruptedException  thrown by taking a buffer
@throws IOException if an error happened during accept