Article View: gnu.emacs.bug
Article #99679open-network-stream does not know about n.n.n.n addresses
From: Hannu Aronsson
Date: Tue, 03 Jul 1990 14:44
Date: Tue, 03 Jul 1990 14:44
84 lines
3849 bytes
3849 bytes
This is not a serious problem, more like a suggestion for a useful
feature.
PROBLEM
`open-network-stream' in Emacs does not recognize addresses in the
number.number.number.number format (i.e. 130.233.40.32).
I think this address format should work, otherwise there will be
problems when your /etc/hosts or nameserver is not in very good
working order.
``DISCUSSION''
This functionality *should* be in the library routine
gethostbyname(), but for those without source changing that is hard,
and the easiest way for *now* would be to patch the applications.
I think this change would be beneficial for some Emacs users
especially under strange/panic conditions, and not changing any
previous practises.
There is a library function (in BSD at least), gethostbyaddr()
which is unfortunately quite badly documented. With it it is very easy
to add this functionality to Emacs. I have enclosed a sample
quick-hack, something like that should work.
Another good idea might be to try all the addresses, if the
gethostby*() returns a list of addresses, usually some of those
addresses works even if the first does not work. Of course this works
only in newer BSD-like systems.
I encountered these problems when I was trying to read local news
with GNUS and NNTP from another organization; Our nameservers randomly
either did not know or returned multiple addresses for the host.
OTHER INFORMATION
M-x emacs-version: GNU Emacs 18.55.7 of Tue Jul 3 1990 on
joker.hut.fi (berkeley-unix).
MY QUICK HACK
This is how I quickly hacked around this problem (i.e. it is a
kludge). The code below should work on most machines with BSD
libraries and 32 bit ints&longs etc. You can see here what kind of
arguments gethostbyaddr() wants, if not more.
In ~emacs/src/process.c:
---begin-of-kludge------begin-of-kludge------begin-of-kludge---
...
host_info = gethostbyname (XSTRING (host)->data);
/* ------------- following code inserted/changed ------------- */
if (host_info == 0) {
/* Try n.n.n.n format when by-name fails */
#if defined(BSD) /* Does not work properly on others, */
/* I suppose */
unsigned char addr[4];
unsigned long temp;
temp = inet_addr(XSTRING (host)->data);
addr[0] = (temp & 0xFF000000) >>24; /* The arg for gethostbyaddr */
addr[1] = (temp & 0x00FF0000) >>16; /* is not documented too well. */
addr[2] = (temp & 0x0000FF00) >>8; /* This seems to work. */
addr[3] = (temp & 0x000000FF);
host_info = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
if (host_info == 0)
#endif defined(BSD)
error ("Unknown host \"%s\"", XSTRING(host)->data);
}
/* ------------ end of inserted/changed code ------------- */
bzero (&address, sizeof address);
...
---end-of-kludge------end-of-kludge------end-of-kludge---
Thank you for reading this message. I hope it helps you to create a
better Emacs for everyone to enjoy!
rgds//haa
--
Hannu Aronsson <haa@cs.hut.fi>
Dept. of Computer Science, CS lab,
Helsinki University of Technology, Finland
Technical Details
Message-ID:
<9007031444.AA24031@hutcs.hut.fi>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!SAUNA.HUT.FI!haaShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,67c2fbffbff626b1,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-07-03 09:40:29 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!SAUNA.HUT.FI!haa From: haa@SAUNA.HUT.FI (Hannu Aronsson) Newsgroups: gnu.emacs.bug Subject: open-network-stream does not know about n.n.n.n addresses Message-ID: <9007031444.AA24031@hutcs.hut.fi> Date: 3 Jul 90 14:44:28 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: Helsinki University of Technology, Finland Lines: 84 Posted: Tue Jul 3 15:44:28 1990