snafu has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl # Jim Conner 4/30/2001 use IO::Socket; use strict; use Cwd; ################################################ my $rcon_passwd = "password"; my $peer_addr = "mybox.net"; my $peer_port = "27500"; ################################################ my $socket = IO::Socket::INET->new(PeerAddr => $peer_addr, PeerPort => $peer_port, Proto => 'udp') or die("Cannot open socket to $peer_addr on $peer_port\n"); # Could use "\xff\xff\xff\xff\x0" too my $prep = chr(255)x4; my $send = chr(0); #$socket->send("$prep rcon $rcon_passwd status\n"); print $socket "$prep rcon $rcon_passwd status\r"; while ( <$socket> ) { print; } print "done\n";
Bear in mind that I just started this code tonight and before I even started I didn't think I would be able to even talk to the server, however, here are the logs to show I am:
[Apr 30 02:48:10] Rcon from 192.168.100.14:1285: rcon (hidden) status [Apr 30 02:48:10] net address : 192.132.87.12:27500 [Apr 30 02:48:10] cpu utilization : 0% [Apr 30 02:48:10] avg response time: 1 ms [Apr 30 02:48:10] packets/frame : 0.82 (12) [Apr 30 02:48:10] name userid frags [Apr 30 02:48:10] address rate ping drop [Apr 30 02:48:10] ---------------- ---- ---- ----- [Apr 30 02:48:10] [Apr 30 02:51:49] Rcon from 192.168.100.14:1287: rcon (hidden) status [Apr 30 02:51:49] net address : 192.132.87.12:27500 [Apr 30 02:51:49] cpu utilization : 0% [Apr 30 02:51:49] avg response time: 1 ms [Apr 30 02:51:49] packets/frame : 0.82 (12) [Apr 30 02:51:49] name userid frags [Apr 30 02:51:49] address rate ping drop [Apr 30 02:51:49] ---------------- ---- ---- ----- [Apr 30 02:51:49]I have tried a few ways e.g.
my @OPEN = $socket->send("line"); and
my @OPEN = <$socket>; (which seems to be waiting on output from the server or at least it doesn't do anything once the request is sent ie the script sits there and looks at me funny, but I see the logs grow (tail -f) and no output comes to my perl script *shrug*). I know this can be accomplished since other programs do it (I have an mirc script that does it...and quake admin does it too) so I know I can do it with Perl....somehow. :)
I can at least finish the script, but I still do not get anything from the server. Is it me or quake.
*disclaimer* (: I am new to Perl and am even newer to socket programming. Please be gentle =P
TIA
----------
- Jim
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: IO::Socket::INET, quake, and me...
by t0mas (Priest) on Apr 30, 2001 at 12:06 UTC | |
by Rhandom (Curate) on Apr 30, 2001 at 18:02 UTC | |
by snafu (Chaplain) on Apr 30, 2001 at 17:44 UTC | |
Re: IO::Socket::INET, quake, and me...
by astanley (Beadle) on Apr 30, 2001 at 18:25 UTC | |
Re: IO::Socket::INET, quake, and me...
by HeatSeekerCannibal (Beadle) on Dec 07, 2007 at 17:45 UTC | |
by tye (Sage) on Dec 07, 2007 at 19:26 UTC |