Sending data types in a UDP packet

Discussion in 'Ruby' started by Isaac Wagner, May 3, 2009.

  1. Isaac Wagner

    Isaac Wagner Guest

    In the specific protocol I'm writing a script for, I need to send a lot
    of different data types through the packet, such as U32, and S8.
    (Unsigned 32 bit, signed 8 bit). Does ruby support these types of
    variables? How can I send them through a packet?
    I'm still learning about networking and ruby, so if I said anything that
    doesn't make sense, please forgive me.
    Isaac Wagner, May 3, 2009
    1. Advertisements

  2. The basic way of constructing packets in ruby is with Array#pack, and
    String#unpack on the other end. See the ri docs or the pickaxe book, or
    ask back here for more help.

    There are some libraries that give you a little language for describing
    and manipulating packets, which can simplify your code and make it
    easier to maintain. I wrote bit-struct[1] and there are at least two

    Joel VanderWerf, May 3, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.