From: Daniel Martin Date: 2007-06-26T03:53:45+09:00 Subject: Re: could anyone help me in the question, thanks? Sonn Ygg writes: > How could I do above in Ruby because I don't find how to specify the > data type of variables or the address of variables in Ruby so far? I > will deeply appreciate if anyone gives me any hint about it? Thanks a > lot. This is exactly the problem that Array.pack was designed to solve. Quoting from a recent post of mine dealing with network headers in the FSP protocol: (ruby-talk:256654) fsp_string = [fsp_pkt.cmd, 0, fsp_pkt.key, fsp_pkt.seq, fsp_pkt.len, fsp_pkt.pos].pack("CCnnnN") Basically, make an array containing what you need, then use pack to stuff it into a byte string with the proper width and alignment. Then write that byte string to your socket. -- s=%q( Daniel Martin -- martin@snowplow.org puts "s=%q(#{s})",s.to_a.last ) puts "s=%q(#{s})",s.to_a.last