in reply to Sending a packet and getting reply.

So what is the Ruby code, and what problems did you encounter when moving the Ruby code to Perl?

  • Comment on Re: Sending a packet and getting reply.

Replies are listed 'Best First'.
Re^2: Sending a packet and getting reply.
by Anonymous Monk on Jan 15, 2014 at 11:48 UTC
    Here is a snippet of the ruby code. Im somewhat new to perl so i dont know how i would add it in.
    1_string = "\x97\x00\x00\x00\xAA\x00\x00\x00" socket = UDPSocket.open socket.send(1_string, 0, target_server, target_port) if select([socket], nil, nil, TIMEOUT) response = socket.recvfrom(10)

      What parts are problematic?

      As you know Ruby, I'll give you some simple/simplicistic transaltion rules for Ruby to Perl:

      • Simple variables in Perl need to start with a letter. Also, they are usually prefixed by $.
      • For opening an UDP socket, use IO::Socket::INET. It has almost the same methods as UDPSocket.
      • nil is undef in Perl.
        Thank you for the reply, but im not looking to translate the code. i want to just get an example for this is all.