🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99805

problem & fix in open-network-stream

#99805
From: Boris "relish" Goldowsky
Date: Mon, 07 May 1990 16:53
71 lines
2882 bytes
I looked in vain for any way to connect to a host when you have its
numerical internet address but not its name.  This may not be a
problem for those with name service that always works, but this is not
the case for all.

Here is a fix that works (though it doesn't deal with wrong addresses
very prettily):

*** process.c.ORIG	Fri Jan 19 17:23:33 1990
--- process.c	Wed Jan 24 23:17:30 1990
***************
*** 37,42 ****
--- 37,43 ----
  #include <sys/socket.h>
  #include <netdb.h>
  #include <netinet/in.h>
+ #include <arpa/inet.h>
  #endif /* HAVE_SOCKETS */
  
  #if defined(BSD) || defined(STRIDE)
***************
*** 1130,1136 ****
    register int i;
    struct sockaddr_in address;
    struct servent *svc_info;
!   struct hostent *host_info;
    int s, outch, inch;
    char errstring[80];
    int port;
--- 1131,1139 ----
    register int i;
    struct sockaddr_in address;
    struct servent *svc_info;
!   struct hostent *host_info, given_host_info;
!   char *(given_addr_list[2]);
!   unsigned long given_addr;
    int s, outch, inch;
    char errstring[80];
    int port;
***************
*** 1149,1156 ****
      }
  
    host_info = gethostbyname (XSTRING (host)->data);
!   if (host_info == 0)
!     error ("Unknown host \"%s\"", XSTRING(host)->data);
  
    bzero (&address, sizeof address);
    bcopy (host_info->h_addr, (char *) &address.sin_addr, host_info->h_length);
--- 1152,1171 ----
      }
  
    host_info = gethostbyname (XSTRING (host)->data);
!   if (host_info == 0) {
!       /*  Attempt to interpret the hostname argument
! 	  as a host number */
!       host_info= &given_host_info;
!       given_host_info.h_name=0;
!       given_host_info.h_aliases=0;
!       given_host_info.h_addrtype=AF_INET;
!       given_host_info.h_addr_list = &(given_addr_list[0]);
!       if((given_addr=inet_addr(XSTRING (host)->data))==-1)
! 	  error ("Unknown host \"%s\"", XSTRING(host)->data);
!       given_addr_list[0]=(char*)(&given_addr);
!       given_addr_list[1]=0;
!       given_host_info.h_length=strlen(given_addr_list[0]);
!   }
  
    bzero (&address, sizeof address);
    bcopy (host_info->h_addr, (char *) &address.sin_addr, host_info->h_length);
Technical Details
Message-ID: <9005071653.AA09570@prodigal.psych.rochester.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!PRODIGAL.PSYCH.ROCHESTER.EDU!boris

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,d9e28e113a4d967,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-05-07 22:37:07 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!PRODIGAL.PSYCH.ROCHESTER.EDU!boris
From: boris@PRODIGAL.PSYCH.ROCHESTER.EDU (Boris "relish" Goldowsky)
Newsgroups: gnu.emacs.bug
Subject: problem & fix in open-network-stream
Message-ID: <9005071653.AA09570@prodigal.psych.rochester.edu>
Date: 7 May 90 16:53:01 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 71
Posted: Mon May  7 17:53:01 1990