Function: dictionary-open-server
dictionary-open-server is a byte-compiled function defined in
dictionary.el.gz.
Signature
(dictionary-open-server SERVER)
Documentation
Opens a new connection to SERVER.
The connection takes the proxy setting in customization group
dictionary-proxy into account.
Source Code
;; Defined in /usr/src/emacs/lisp/net/dictionary.el.gz
(defun dictionary-open-server (server)
"Opens a new connection to SERVER.
The connection takes the proxy setting in customization group
`dictionary-proxy' into account."
(let ((wanted 'raw-text)
(coding-system nil))
(if (member wanted (coding-system-list))
(setq coding-system wanted))
(let ((coding-system-for-read coding-system)
(coding-system-for-write coding-system))
(setq dictionary-current-server server)
(message "Opening connection to %s:%s" server
dictionary-port)
(dictionary-connection-close dictionary-connection)
(setq dictionary-connection
(if dictionary-use-http-proxy
(dictionary-connection-open dictionary-proxy-server
dictionary-proxy-port)
(dictionary-connection-open server dictionary-port)))
(set-process-query-on-exit-flag
(dictionary-connection-process dictionary-connection)
nil)
(when dictionary-use-http-proxy
(message "Proxy CONNECT to %s:%d"
dictionary-proxy-server
dictionary-proxy-port)
(dictionary-send-command (format "CONNECT %s:%d HTTP/1.1"
server
dictionary-port))
;; just a \r\n combination
(dictionary-send-command "")
;; read first line of reply
(let* ((reply (dictionary-read-reply))
(reply-list (dictionary-split-string reply)))
;; first item is protocol, second item is code
(unless (= (string-to-number (cadr reply-list)) 200)
(error "Bad reply from proxy server %s" reply))
;; skip the following header lines until empty found
(while (not (equal reply ""))
(setq reply (dictionary-read-reply)))))
(dictionary-check-initial-reply)
(dictionary-send-command (concat "client " dictionary-identification))
(let ((reply (dictionary-read-reply-and-split)))
(message nil)
(unless (dictionary-check-reply reply 250)
(error "Unknown server answer: %s"
(dictionary-reply reply)))))))