At Mon, 20 May 2002 10:49:23 +0900,
Terje Elde wrote:

> I'm starting on a projects which requires me to use a spesific network
> protocol.  This protocol demands that I write certain size fields in Int16,
> and other values as Int32.  The rest is just plain text.

Once I wrote a num/int, just a concept toy and very slow but works. 
http://www.notwork.org/~gotoken/ruby/p/num/

> While looking around I've found little or no indications of how to write a
> number of a spesific size (ie, int16) to a network socket, or how to deal with
> it at all.  I found a seemingly old int package which would allow me to do

Maybe Array#pack and String#unpack can helps to such applications. 
The following lists several format string for pack/unpack:

      char => "c",
      int => "i",
      short => "s",
      long => "l",
      float => "f",
      double => "d",
      unsigned char => "C",
      unsigned int => "I",
      unsigned short => "S",
      unsigned long => "L",
      bigendian unsigned short => "n",
      bigendian unsigned long => "N",
      bigendian float => "g",
      bigendian double => "G",
      littleendian unsigned short => "v",
      littleendian unsigned long => "V",
      littleendian float => "e",
      littleendian double => "E"

I also wrote a joke interface to pack/unpack:
http://www.notwork.org/~gotoken/ruby/p/as-is/pack.rb

Hope this helps,

-- Gotoken