Function: erc-server-connect
erc-server-connect is a byte-compiled function defined in
erc-backend.el.gz.
Signature
(erc-server-connect SERVER PORT BUFFER &optional CLIENT-CERTIFICATE)
Documentation
Perform the connection and login using the specified SERVER and PORT.
We will store server variables in the buffer given by BUFFER.
CLIENT-CERTIFICATE may optionally be used to specify a TLS client
certificate to use for authentication when connecting over
TLS (see erc-session-client-certificate for more details).
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-backend.el.gz
(defun erc-server-connect (server port buffer &optional client-certificate)
"Perform the connection and login using the specified SERVER and PORT.
We will store server variables in the buffer given by BUFFER.
CLIENT-CERTIFICATE may optionally be used to specify a TLS client
certificate to use for authentication when connecting over
TLS (see `erc-session-client-certificate' for more details)."
(when (string-match erc--server-connect-dumb-ipv6-regexp server)
(setq server (match-string 1 server)))
(let ((msg (erc-format-message 'connect ?S server ?p port)) process
(args `(,(format "erc-%s-%s" server port) nil ,server ,port)))
(when client-certificate
(setq args `(,@args :client-certificate ,client-certificate)))
(message "%s" msg)
(setq process (apply erc-server-connect-function args))
(unless (processp process)
(error "Connection attempt failed"))
;; Misc server variables
(with-current-buffer buffer
(setq erc-server-filter-data nil)
(setq erc-server-process process)
(setq erc-server-quitting nil)
(setq erc-server-reconnecting nil
erc--server-reconnect-timer nil)
(setq erc-server-timed-out nil)
(setq erc-server-banned nil)
(setq erc-server-error-occurred nil)
(let ((time (erc-current-time)))
(setq erc-server-last-sent-time time)
(setq erc-server-last-ping-time time)
(setq erc-server-last-received-time time))
(setq erc-server-lines-sent 0)
;; last peers (sender and receiver)
(setq erc-server-last-peers (cons nil nil)))
;; we do our own encoding and decoding
(when (fboundp 'set-process-coding-system)
(set-process-coding-system process 'raw-text))
;; process handlers
(set-process-sentinel process #'erc-process-sentinel)
(set-process-filter process #'erc-server-filter-function)
(set-process-buffer process buffer)
(erc-log "\n\n\n********************************************\n")
(message "%s" (erc-format-message
'login ?n
(with-current-buffer buffer (erc-current-nick))))
;; wait with script loading until we receive a confirmation (first
;; MOTD line)
(if (eq (process-status process) 'connect)
;; waiting for a non-blocking connect - keep the user informed
(erc-display-message nil nil buffer "Opening connection..\n")
(message "%s...done" msg)
(erc--register-connection))))