// create a new Selector for use below
selector = Selector.open();
// set the port the server channel will listen to
serverSocket.bind (new InetSocketAddress (getBind(),getTcpListenPort()));
// set non-blocking mode for the listening socket
serverChannel.configureBlocking (false);
// register the ServerSocketChannel with the Selector
serverChannel.register (selector, SelectionKey.OP_ACCEPT);
while (doListen && selector != null) {
// this may block for a long time, upon return the
// selected set contains keys of the ready channels