Function: erc-normalize-port

erc-normalize-port is a byte-compiled function defined in erc.el.gz.

Signature

(erc-normalize-port PORT)

Documentation

Normalize the port specification PORT to integer form.

PORT may be an integer, a string or a symbol. If it is a string or a symbol, it may have these values:
* irc -> 194
* ircs -> 994
* ircd -> 6667
* ircd-dalnet -> 7000

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-normalize-port (port)
  "Normalize the port specification PORT to integer form.
PORT may be an integer, a string or a symbol.  If it is a string or a
symbol, it may have these values:
* irc         -> 194
* ircs        -> 994
* ircd        -> 6667
* ircd-dalnet -> 7000"
  ;; These were updated somewhat in 2022 to reflect modern standards
  ;; and practices.  See also:
  ;;
  ;; https://datatracker.ietf.org/doc/html/rfc7194#section-1
  ;; https://www.iana.org/assignments/service-names-port-numbers
  (cond
   ((symbolp port)
    (erc-normalize-port (symbol-name port)))
   ((stringp port)
    (let ((port-nr (string-to-number port)))
      (cond
       ((> port-nr 0)
        port-nr)
       ((string-equal port "irc")
        194)
       ((string-equal port "ircs")
        994)
       ((string-equal port "ircu") 6667) ; 6665-6669
       ((string-equal port "ircd") ; nonstandard (irc-serv is 529)
        6667)
       ((string-equal port "ircs-u") 6697)
       ((string-equal port "ircd-dalnet")
        7000)
       (t
        nil))))
   ((numberp port)
    port)
   (t
    nil)))