Gnus development mailing list
 help / color / mirror / Atom feed
* Help defadvising nnimap-open-connection
@ 2001-01-03 18:42 Jake Colman
  2001-01-03 23:00 ` Christoph Conrad
  0 siblings, 1 reply; 2+ messages in thread
From: Jake Colman @ 2001-01-03 18:42 UTC (permalink / raw)
  Cc: Simon Josefsson


In a previous post on this list, Christoph Conrad discusses a problem with
nntp-open-network-stream with respect to hangs when a connection problem
occurs.  He resolved the problem with with the following piece of advice:

        (defadvice open-network-stream
          ( before nntp-open-network-stream-resolve act )
            (when (not (string-match "[0-9.]+" (ad-get-arg 2)))
              (ad-set-arg 2 (cc-resolve-address nntp-address))))

The function cc-resolve-address converts a host name to a host IP address
using nslookup.

Since I see the same problem quite regularly when connecting to my imap
server, I attempted the following piece of advice:

        (defadvice nnimap-open-connection
          (before nnimap-open-connection-resolve act)
          (when (not (string-match "[0-9.]+" (ad-get-arg 0)))
            (ad-set-arg 0 (cc-resolve-address nnimap-address))))

When I do this, I end up crashing because nnimap-server-buffer is nil in
nnimap-open-server.  Can someone (Simon?) help me figure out how to do this?
Basically, I want to transparently replace the imap host name with the imap
IP address so that the actual connection is done via the address.

For completeness sake, here is the cc-resolve-address function:

(defun cc-resolve-address( domain )
  "Helper function for advised open-network-stream function"
  (save-excursion
    (let ((output-buf (generate-new-buffer " *resolve-address*")))
      (unwind-protect
          (progn
            (set-buffer output-buf)
            (and (eq (call-process
                      "/usr/sbin/nslookup" nil output-buf nil
                      "-retries=1" domain)
                     0)
                 (> (point-max) 2)
                 (goto-char (point-max))
                 (when (re-search-backward (concat "^Name: [ ]*"
                                                   domain
                                                   "\n"
                                                   "Address: [ ]*\\(.*\\)$")
                                           nil t)
                   (match-string 1))))
        ;; unwind-protect cleanup
        (kill-buffer output-buf)))))


TIA!

-- 
Jake Colman                     

Principia Partners LLC                  Phone: (201) 946-0300
Harborside Financial Center               Fax: (201) 946-0320
902 Plaza II                           Beeper: (800) 928-4640
Jersey City, NJ 07311                  E-mail: colman@ppllc.com
                                       E-mail: jcolman@jnc.com
                                          web: http://www.ppllc.com

microsoft: "where do you want to go today?"
linux:     "where do you want to go tomorrow?"
BSD:       "are you guys coming, or what?"




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-01-03 23:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-03 18:42 Help defadvising nnimap-open-connection Jake Colman
2001-01-03 23:00 ` Christoph Conrad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).