Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Net::IRC does not connect

by larsen (Parson)
on May 02, 2001 at 23:34 UTC ( #77481=perlquestion: print w/ replies, xml ) Need Help??
larsen has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to do some experiment with Net::IRC, but I have major problems. First of all, look at the beginning of the program I wrote:
#!/urs/bin/perl use strict; use Net::IRC; use LWP::Simple; use HTML::Parser; use Data::Dumper; my $bot = new Net::IRC; my $connection = $bot->newconn(Nick => 'HAL', Server => 'irc.tin.it', Port => '6667', Ircname => 'some name...', UserName => 'HAL' ) || die "Can't connect - $!\n"; # Add handlers here... $bot->start;
...omissis...

It's very similar to the beginning of irctest, the script that is provided with Net::IRC package. Despite of this fact, it does not work. irctest neither. They both give to me an error message:

Can't connect to irc.tin.it:6667! at /usr/lib/perl5/site_perl/5.6.0/Net/IRC.pm line 192
Can't connect - Bad file descriptor

So I tried to look into the code of the module. Line 192 of IRC.pm is the line that requests a new instance of Connection:

my $conn = Net::IRC::Connection->new($self, @_);

So I looked closer in the code... Here the code that fails (from Connection.pm):

if (connect( $sock, sockaddr_in($self->port, inet_aton($self->server)) + )) { $self->socket($sock); } else { carp (sprintf "Can't connect to %s:%s!", $self->server, $self->por +t); $self->error(1); return; }
$self->port and $self->server are well defined, and $sock is created with the socket function, so it seems to me the problem is not in my code. Since I'm convinced that Net::IRC would work (I didn't have problem when I installed it from CPAN), I ask you if it may depend on my system configuration (I use RedHat Linux and Perl 5.6.0) and how could I solve the problem.

Comment on Net::IRC does not connect
Select or Download Code
Re: Net::IRC does not connect
by illitrit (Friar) on May 02, 2001 at 23:45 UTC
    I'm not familiar with Net::IRC however I am aware that it is no longer supported by it's author.

    The author suggests using POE::Component::IRC now.

    Hope this helps in the long run.

    James
Re: Net::IRC does not connect
by le (Friar) on May 02, 2001 at 23:47 UTC
    I had similar problems here, using Net::IRC version 0.7.

    After digging around a little in the code, I found that in Net::IRC::Connection, in the connect() sub, Symbol.pm's "gensym" method was used to create an anonymous glob, which then was turned into a socket (the code snippets you posted, plus a few more).

    A little above this code, I found a commented section of code, that uses IO::Socket to create a socket.
    $sock = IO::Socket::INET->new(PeerAddr => $self->server, PeerPort => $self->port, Proto => "tcp", );
    I took this code, commented out the rest, and voila - it worked. I have no idea, why the author of Net::IRC used the gensym() approach and not the IO::Socket way.

    Hope this helps.

    P.S.: In my firewall logs I found out, that when I used the original Net::IRC, the irctest scripts tried to connect to the IRC-server with a local address of 127.0.0.1 - which of course can't work.
      I am facing the same problem with Net::IRC but I am not entirely sure what to comment out, could you please upload either the file or send it to me at linuxlc@iname.com?

      Thanks in advance

      Imagination is more important then knowledge -Einstein-

        Sorry that I didn't reply earlier.

        In Net::IRC::Connection, there's a connect() sub, that has this piece of code:
        # my $sock = IO::Socket::INET->new(PeerAddr => $self->server, # PeerPort => $self->port, # Proto => "tcp", # ); $sock = Symbol::gensym(); unless (socket( $sock, PF_INET, SOCK_STREAM, getprotobyname('tcp') + )) { carp ("Can't create a new socket: $!"); $self->error(1); return; }
        Uncomment the upper part and comment out the part below, it should work then.
        Thanks for your reply anyway

        But I made the switch to POE::Component::IRC

        Imagination is more important then knowledge -Einstein-

Re: Net::IRC does not connect
by dragonchild (Archbishop) on Feb 17, 2005 at 18:55 UTC
    (I didn't have problem when I installed it from CPAN)

    That's because none of the tests failed. Since about 30-50% of all distros on CPAN have, as their complete test suite, a file that basically goes:

    use Test::More 'no_plan'; use_ok( My::Module ); isa_ok( My::Module->new, 'My::Module' );

    That doesn't really test much, does it?

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://77481]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-09-16 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (36 votes), past polls