At 06:14 PM 5/15/2002 -0400, [EMAIL PROTECTED] wrote:
>I've narrowed down a portion of the trouble
>that I have seen with some of the gethostby*()
>routines to: netdb.h.  I

Peter,

Thanks for working on this.  With that head start I am now able to nail the 
exact problem with gethostbyaddr, though integrating a fix into Perl will 
still be a bit messy.  With the socktest.c program at the end of this 
message, I get an address length of 58 by using the headers and routines 
supplied with the C RTL:

$ cc/prefix=all socktest
$ link socktest
$ run socktest
70100022
localhost
2
58

but if I use the Multinet headers and routines I get the correct length of 4:

$ cc/prefix=all socktest/define=MULTINET_SOCKETS
$ link socktest, sys$input:/opt
MULTINET:MULTINET_SOCKET_LIBRARY.EXE/SHARE
^Z 
$ run socktest
70100022
localhost
2
4
(null)
(null)

Making use of this will be a bit of a mess since configure.com will have to 
detect Multinet and define the MULTINET_SOCKETS macro.  Then probably 
sockadapt.h will have to be modified to include the alternate headers when 
the macro is defined.  Then one of the linker options files (I'm not sure 
which one) will need to have a line added to link against the Multinet 
socket library.  Any takers?

$ type socktest.c
#ifdef SOCKADDR_LEN
# define _SOCKADDR_LEN
#endif
#ifdef MULTINET_SOCKETS
/* must link against MULTINET:MULTINET_SOCKET_LIBRARY.EXE/SHARE */
# include  "multinet_root:[multinet.include.sys]types.h"
# include  "multinet_root:[multinet.include.netinet]in.h"
# include  "multinet_root:[multinet.include.arpa]inet.h"
# include  "multinet_root:[multinet.include.sys]socket.h"
# include  "multinet_root:[multinet.include]netdb.h"
#else
#include  <errno.h>
#include  <in.h>
#include  <inet.h>
# include  <netdb.h>  /* the Compaq C one (UCX) */
#endif
#include <socket.h>
#include <stdio.h>
#ifndef __CRTL_VER
# define __CRTL_VER __VMS_VER
#endif

extern int sys_nerr;
extern int h_errno;


int main() {
    struct hostent *h;
    struct in_addr myaddr;
    printf( "%d\n", __CRTL_VER );
    myaddr.s_addr = inet_addr("127.0.0.1");
    h = gethostbyaddr( (char*) &myaddr, 4, AF_INET );
    if ( h != NULL ) {
        printf( "%s\n", h->h_name );
        printf( "%d\n", h->h_addrtype );
        printf( "%d\n", h->h_length );
#ifdef MULTINET_SOCKETS
        printf( "%s\n", h->h_cputype );
        printf( "%s\n", h->h_opsys );
#endif
    }
    else {
        printf( "h is null\n" );
        herror( "h " );
    }
    return(0);
}

Reply via email to