Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, This code used to work perfectly:
sub OpenClient{ my $self =shift; use IO::Socket; $client = IO::Socket::INET->new(Proto =>$ENV{FPPPRO}, LocalPort=>$ENV{FPPORT}, Listen =>$ENV{FPMAXCON}, Reuse =>1) || $self->Usage ("Ca +n't start client: $!"); $self->WriteLog ("Client running: Port:$ENV{FPPORT} Maxconnections +:$ENV{FPMA}ON}");
But now it is broke. I've tried horcoding in the $ENV vars, but I still get the same result. Heck, even when I try the examples from the book, I still can't open the socket. Have I lost my mind oh great ones?

Replies are listed 'Best First'.
Re: perl socket doesn't work anymore
by themage (Friar) on Nov 30, 2006 at 15:56 UTC
    Hi,

    knowing what's on your FPPPRO, FPPORT and FPMAXCON could help us helping you.

    Note: in the WriteLog param you have $ENV{FPMA}ON}. I presume that the first } sould be an X.

    TheMage
    Talking Web
      Good point, sorry: FPPORT = 5596 FPPPRO = tcp FPMAXCON = 5
        Hi,

        Looks ok for me. On your code replace:
        $self->Usage ("Can't start client: $!");
        with
        $self->Usage ("Can't start client: $@");
        And now, when you say it don't work, you mean that, more specificly? The socket is not opening, which error are you getting in $@?

        TheMage
        Talking Web
Re: perl socket doesn't work anymore
by ikegami (Patriarch) on Nov 30, 2006 at 16:19 UTC
      ok, this $@ is cool: Program: /var/opt/FirePower/bin/fireclient.pl Version: 2.0.0 Message: Can't start client: IO::Socket::INET: Bad protocol 'tcp' Usage: Why would tcp all of a sudden be a bad protocol? This is on solaris 8
        The protocol name is converted to a protocol number using getprotobyname, which serves as an interface to /etc/protocols. Maybe it changed? Maybe you're running under chroot and there's no etc/protocols under your virtual root?