-#!/usr/bin/perl -w \r
-\r
-use IO::Socket; \r
-use Net::hostent; \r
-\r
-my $port = shift || 13131; \r
-\r
-my $server = IO::Socket::INET->new(\r
- Proto => 'tcp', \r
- LocalPort => $port, \r
- Listen => SOMAXCONN, \r
- Reuse => 1 )\r
- || die "can't setup server"; \r
-print "[Q3Map2 listener $0 is now active on port $port]\n"; \r
-\r
-while( $client = $server->accept() )\r
-{ \r
-\r
- $client->autoflush( 1 ); \r
- \r
- $hostinfo = gethostbyaddr( $client->peeraddr );\r
- printf "[Connect from %s]\n\n", $hostinfo ? $hostinfo->name : $client->peerhost; \r
- \r
- #ask the client for a command \r
- print $client "[server]\$";\r
- my $text = "";\r
- while( <$client> )\r
- {\r
- $text .= $_;\r
- while( $text =~ s|<message[^>]*>([^<]+)</message>|| )\r
- {\r
- my $msg = $1;\r
- \r
- # fix xml ents\r
- $msg =~ s|<|<|g;\r
- $msg =~ s|>|>|g;\r
- $msg =~ s|"|"|g;#"\r
- $msg =~ s|'|'|g;#'\r
- \r
- print $msg;\r
- }\r
- }\r
- \r
- printf "\n[Disconnected: %s]\n\n", $hostinfo ? $hostinfo->name : $client->peerhost; \r
- close $client;\r
-} \r
+#!/usr/bin/perl -w
+
+use IO::Socket;
+use Net::hostent;
+
+my $port = shift || 13131;
+
+my $server = IO::Socket::INET->new(
+ Proto => 'tcp',
+ LocalPort => $port,
+ Listen => SOMAXCONN,
+ Reuse => 1 )
+ || die "can't setup server";
+print "[Q3Map2 listener $0 is now active on port $port]\n";
+
+while( $client = $server->accept() )
+{
+
+ $client->autoflush( 1 );
+
+ $hostinfo = gethostbyaddr( $client->peeraddr );
+ printf "[Connect from %s]\n\n", $hostinfo ? $hostinfo->name : $client->peerhost;
+
+ #ask the client for a command
+ print $client "[server]\$";
+ my $text = "";
+ while( <$client> )
+ {
+ $text .= $_;
+ while( $text =~ s|<message[^>]*>([^<]+)</message>|| )
+ {
+ my $msg = $1;
+
+ # fix xml ents
+ $msg =~ s|<|<|g;
+ $msg =~ s|>|>|g;
+ $msg =~ s|"|"|g;#"
+ $msg =~ s|'|'|g;#'
+
+ print $msg;
+ }
+ }
+
+ printf "\n[Disconnected: %s]\n\n", $hostinfo ? $hostinfo->name : $client->peerhost;
+ close $client;
+}