Re: "connection refused" and mo

Jack Shirazi - BIU (js@bison.lif.icnet.uk)
Fri, 16 Sep 94 11:06:34 BST


One observation that will probably never matter: the second argument
to the socket call should actually be &main'PF_INET.

It shouldn't matter because I don't think any system ever has
PF_INET and AF_INET set to different values. In fact all the systems
I've ever seen define one in terms of the other.

>     $that = pack('S n a4 x8', &main'AF_INET, $port, $thataddr);
>     if (! socket(FS, &main'AF_INET, &main'SOCK_STREAM, 0))


Another thing which might be of use: the only things required from
sys/socket.ph as far as I'm aware are the above defines. The following
routine will print out your own "socket.ph" which will contain
the required values - this could be included as help in libwww for
people who experience these problems:


#!/usr/local/bin/perl
#Run this and put its output into a file called something like
#"my_sys_socket.ph" in the libwww directory, then replace the 
#'require "sys/socket.ph";'
#line in wwwhttp.pl with
#'require "my_sys_socket.ph"'
#if there are socket.ph problems

foreach $name ("AF_INET","PF_INET","SOCK_DGRAM","SOCK_STREAM") {
    print "sub $name {",&look_for_integer_define($name,"sys/socket.h"),"};\n";
}


sub look_for_define {
    local($define,$include_file,@includes) = @_;
    local($var);
    open(INCLUDE,"/usr/include/$include_file") ||
           die "Error: Unable to find include file $include_file\n";
    while(<INCLUDE>) {
        /^\s*#include\s+<([^>]*)>/ && push(@includes,$1);
        /^\s*#define\s+$define\s+(\S+)\b/ && ($var = $1,last);
    }
    close INCLUDE;
    if(defined($var)) {return $var;}
    if ($#includes == -1) {die "Error: Unable to find definition for $define\n";}
    &look_for_define($define,@includes);
}

sub look_for_integer_define {
    local($define,$include_file) = @_;
    local($var);
    $var = &look_for_define($define,$include_file);
    if ($var =~ /^\d+$/) {return $var;}
    &look_for_integer_define($var,$include_file);
}

__END__