private void select() throws IOException {
		selector.selectNow();
		
		
        Set<SelectionKey> readyKeys = selector.selectedKeys();
        Iterator<SelectionKey> i = readyKeys.iterator();
        
		while(i.hasNext()) {
			SelectionKey sk = i.next();
			i.remove();
			
			if (sk.isAcceptable()) {
				accept();
				continue;
			}

			WebSocketUser user = (WebSocketUser) sk.attachment();

			try {
				if (sk.isWritable()) {
					user.write();
				}
	
				if (sk.isValid() && sk.isReadable()) {
					if(user.read() == false) {
						user.close();
					}
				}
			} catch(Exception e) {
				logger.error(e.getMessage(),e);
			}
		}
	}