code: public static Buffer consumePort(final Buffer buffer) throws IOException {
          int count = 0;
          final int index = buffer.getReaderIndex();
          boolean done = false;
          while (!done && buffer.hasReadableBytes()) {
              if (isDigit(buffer.readByte())) {
                  ++count;
              } else {
                  done = true;
              }
          }
  
          buffer.setReaderIndex(index);
          if (count != 0) {
              return buffer.readBytes(count);
          }
  
          return null;
      }
docs: Consume a port, which according to RFC 3261 is:
  
  port = 1*DIGIT
  
  @param buffer
  @return the buffer containing only digits or null if there was none fun.
  @throws IOException