Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending UDP packets with Perl5

Status
Not open for further replies.

kasuals

Programmer
Apr 28, 2002
100
US
I need to send a UDP packet to a server in perl. However, I'm not sure how to do the following:

The packet should start with 4 consecutive bytes of 255 (32-bit integer -1) and the string.

So what does that mean? What exactly do I place in front of my string?

ALT-255? That doesn't seem to work when I send the packet. I'm a little confused... any help would be greatly appreciated. - "Delightfully confusing..." raves The New York Times

-Kas
 
I hope you are using the IO::Socket perl module. Or I suggest you downloading it.
IF you need more help let me know and I will post you an example how to create an using UDP sockets....
 
I am now... haha. I tried using the built in Socket module, but it's horrible... I don't know if it even works...

I'm using IO::Socket now... basically I'm trying to send a UDP packet to a Counter-Strike server for this project. I haven't worked with sockets in perl in over 2 years, and never a client side UDP script.

Basically, I need to send commands to the Counter-Strike server through UDP, to port 27015, with 4 255s placed before the command I want it to process. So far my script looks like this:

Basically, to initiate the connection to the server, I'll have to send

255255255255challenge rcon\n

Then the server will respond with:

challenge rcon n

Where N is the rcon number that you place into each future command for tracking purposes.

#!/usr/bin/perl5

use IO::Socket;

$rcon = new IO::Socket::INET( PeerAddr => '216.122.108.91',
PeerPort => 27015,
Proto => 'udp' );

Where should I go from there? - "Delightfully confusing..." raves The New York Times

-Kas
 
Kas,

Have a look at 'perldoc perlipc', there are some good examples there. Mike
________________________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Also, see the pack and unpack functions in the perlfunc manual reference. For example:
Code:
$bits = pack( "C4A*", ( 255,255,255,255,"challenge rcon" ) );
Will create the binary data you wish to transmit.
Cheers, Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top