I am writing a script that will have the ability to connect to a quake server and do some things with rcon. I have the communications part half done which brings me to this. Does anyone have any thoughts on why when I send a command to the server I don't get anything back from the server? I know the command gets to the server because I see it come over the log. However, the server doesn't communicate back to my script. Here is some code. Perhaps someone can find what I am doing wrong. On the other hand this maybe a quake-ism that I need to know something about to get this to work.

#!/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


In reply to IO::Socket::INET, quake, and me... by snafu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.