public function setPort($port = null)
    {
        if (is_null($port) || is_int($port)) {
            $this->port = $port;
        }
        else if (is_string($port) && preg_match('/^[0-9]+$/', $port) !== 0) {
            $this->port = (int) $port;
        }
        else {
            throw new \InvalidArgumentException(
                "invalid value provided for 'port'; ".
                "expecting an integer, string of integers, or null"
            );
        }
        return $this;
    }