Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

irc via telnet, how to auto-pong?

Name: Anonymous 2008-02-02 13:23

Hello.

I'm using irc via telnet to learn more about the raw protocol. Everything runs smoothly except one thing that I find annoying. I need to reply to ping with pong <message from ping> every time the server requests it, otherwise it will disconnect me (ping timeout). Because of this I can't idle out and need to pay attention to ping requests. I'm trying to find some way to still use telnet normally only to make those pong replies more automatic so I can do something else. I tried googling and asking around on irc channels, but to no success so far. Any ideas? I'm connecting from a *nix server.

Name: Anonymous 2008-02-03 4:42

OK, from various examples, faqs and with a bit of luck I managed to write:

#!/usr/bin/perl

use IO::Socket;

$sock = IO::Socket::INET->new('localhost:6667') or die "can't connect $!";

if (fork()) {
    select($sock);
    print while <STDIN>;  # everything from stdin to socket
} else {
    while ($line = <$sock>) {
        if ($line =~ /^PING/) {
            print $sock "PONG :" . (split(/ :/, $line))[1];
        } else {
            print $line;
        }
    }
}


...and it does exactly what I wanted! It's like a normal telnet session to irc only without the annoying ping-pong part. I'm using it now as my irc client.

>>4 >>5 >>13 >>18 >>19 >>21 >>22

Thanks for posting!

>>2 >>8 >>10 >>12 >>15

Go hump a tree.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List