Hello,
Well, this is the last time I am going to bring this up. I am on Apache NT,
and I have the following .pm file that I believe I localized everything in
order to create a socket. The code below does work.  But it never makes a
new socket. As you can see I print out the IO::Socket::GLOB and it shows the
same 'reference' 10xff036c each time through. I realize this is because I am
not closing and undef the $sock. (see the commented close and undef towards
the end). But this works. Except if I shut down the machine I am calling the
socket on. Then it dies and never comes back unless I reboot apache. Not a
good work position to get a web site into.

But here is the catch. If I do close the socket and either undef or even
leave that commented out, I only get one send to the socket, and one reply,
but it never sends another reply to the server and never gets another
response back? But yes, it creates a new socket ref each time?

This confuses me so. If I close the socket, then it shows that I am creating
a new socket, but it never sends or gets a new response. But the rest of the
behavior is proper.

I was just hoping someone could look below, see if they see anything
obviously wrong and reply, or else I am left to believe that this is
possibly a threading issue with the sockets on NT?

I am going to switch to ActiveStates plex, but still would like to continue
striving towards getting the apache running with this code. So there is no
rush on this, it just makes no sense, and I hate to leave open-ended issues.

Thanks for your time,
Scott



package q2;

use IO::Socket;
my $sock;

sub tryQuery {
    unless ($sock) {
        print "No sock making it<br>\n";
        $sock = IO::Socket::INET->new(Proto => 'tcp', PeerAddr =>
'208.238.162.204', PeerPort => '8000') or die (@!);
        $sock->autoflush(1);
    }
    my ($querystring,$fieldlist,$dbpathlist,$type) = @_;
    print "$querystring is QS<br>\n";
    print "$fieldlist   is FL<br>\n";
    print "$dbpathlist  is DB<br>\n";
    print "$type        is TP<br>\n";

    my $message  =
"DBASEQUERY\n$type\n$querystring\nLIST\tFIELDS\n$fieldlist\nENDLIST\nLIST\tD
BASES\n$dbpathlist\nENDLIST\n";

    &ask($message);
}

sub ask {
    my $message = shift;
    print "$message is our message<br>\n";
    my $msgid = int(rand(1000));
    $message = $msgid . "\t" . $message;
    my $msgsize = length($message);
    print "here is our line " . $sock . "\%BEGIN\t$msgsize\n$message SHOIULD
BE GOLDEN";
    print $sock "\%BEGIN\t$msgsize\n$message";
    my $result = <$sock>;
    print "$result is first result from Q<br>\n";
    my $response;
    $result =~ s/\D//g;
    print "$result is should now be digits<br>\n";
    print "$sock is our sock<br>\n";
    read($sock, $response, $result);
    print "$response is our response<br>\n";
#    close($sock);
#   undef $sock;
}




1;




Scott Purcell

Reply via email to