[comp.windows.x] connections to numeric host names

dwig@b11.ingr.com (David Wiggins) (07/19/90)

We have a problem making X connections to hosts whose names are pure
numbers, e.g.  2020.  MakeTCPConnection (XConnDis.c) tries to use this
as an IP address instead of a host name.  This appears to succeed
(inet_addr does not return INVALID_INETADDR), but the connect fails
because there's no machine with that address on the network. 

What we'd like to do is change Xlib to interpret the hostname string as
a hostname first (via gethostbyname), and if there's no such host,
interpret it as an IP address (via inet_addr), effectively reversing the
order that Xlib currently uses.  Would this introduce any new problems?
I balk at changing the order because the following comment...

    /*
     * if numeric host name then try to parse it as such; do the number
     * first because some systems return garbage instead of INVALID_INETADDR
     */

...indicates that there was a good reason for the current order.  Anybody
understand what this comment means?

David P. Wiggins	dwig@ingr.com  or  uunet!ingr!dwig	(205)730-6365
Intergraph Corporation, One Madison Industrial Park, Huntsville, AL 35807

casey@gauss.llnl.gov (Casey Leedom) (07/27/90)

| From: dwig@b11.ingr.com (David Wiggins)
| 
| We have a problem making X connections to hosts whose names are pure
| numbers, e.g.  2020.  MakeTCPConnection (XConnDis.c) tries to use this
| as an IP address instead of a host name.
| 
| What we'd like to do is change Xlib to interpret the hostname string as
| a hostname first, and if there's no such host, interpret it as an IP
| address ... I balk at changing the order because the following comment...
| 
|     /*
|      * if numeric host name then try to parse it as such; do the number
|      * first because some systems return garbage instead of INVALID_INETADDR
|      */
| 
| ...indicates that there was a good reason for the current order.

  From RFC-952, page 1 discussing the format of host names (among others):

	1. A "name" (Net, Host, Gateway, or Domain name) is a text string up
	to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus
	sign (-), and period (.).  Note that periods are only allowed when
	they serve to delimit components of "domain style names".  (See
	RFC-921, "Domain Name System Implementation Schedule", for
	background).  No blank or space characters are permitted as part of a
	name.  No disinction is made between  upper and lower case.  The first
	character must be an alpha character.  The last character must not be
	a minus sign or a period. ...

(Note that RFC-1122 or RFC-1123 probably has something to say about this also
but I *still* haven't had time to read through them. (sigh))

  Thus, if a name begins with a non-alpha, it's not a ``host name''.  It must
be some other method of naming a host.  If it begins with a numeric digit,
it's a good guess that the host is being named via its IP address.

Casey