#!/usr/bin/perl ###################### # REQUIRE PERL 5.002 # ###################### require 5.002; ################# # USE LIBRARIES # ################# use Socket; use POSIX ":sys_wait_h"; if (lc($^O) eq 'mswin32') { $win321 = ''; $mfail = "[FAILED]"; $mok = "[ OK ]"; } else { $win321 = './'; $mfail = "[FAILED]"; $mok = "[ OK ]"; } ##################### # CONNECT TO SERVER # ##################### print "Connecting to server..."; $remote = "64.191.51.88"; $port = 6000; if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') } $iaddr = inet_aton($remote) or die "$mfail (invalid host: $remote)\n"; $paddr = sockaddr_in($port,$iaddr); $proto = getprotobyname('tcp'); socket(SOCK,PF_INET,SOCK_STREAM,$proto) or die "$mfail (socket error: $!)\n"; connect(SOCK, $paddr) or die "$mfail (connect error: $!)\n"; print "$mok (connected to ${remote}:${port})\n"; $nl = chr(13); $nl = $nl.chr(10); snd("connect Name Password"); snd("color \"\"H2G88888\!\#\!"); snd("desc Test"); snd("wh Kage Online!"); ###################### ##################### #################### #START OF SOCKET READ LOOP #################### ##################### ###################### STARTOFLOOP: while ($line = ) { #$lastmsgtime = time(); #$line =~ s/\027-\036\004-\025\376\377//gi; ################ # EXTRACT VARS # ################ #$hostmask = substr($line,index($line,":")); #$mtext = substr($line,index($line,":",index($line,":")+1)+1); #($hostmask, $command) = split(" ",substr($line,index($line,":")+1)); #($nickname) = split("!",$hostmask); #@spacesplit = split(" ",$line); #$mtext =~ s/[\r|\n]//g; if ($line == "(Kage: quit") { die("Manual quit."); } next STARTOFLOOP; } ############## # SND TO SERV ############## sub snd { my ($text) = @_; chomp($text); $text = $text.$nl; if ($verbose eq "on") { print "Out: ".$text } send(SOCK,$text,0); return; }