From: Joel VanderWerf Date: 2007-05-25T06:51:02+09:00 Subject: Re: sending data, no strings via socket Javier Isassi wrote: > class Tdata < BitStruct > unsigned :type, 32 > rest :buf > end > > data = Tdata.new > data.type = 987 #03DB > data.buf = "push to talk" > > socket = TCPSocket.new(home,port) > > server writes..... > 0000: 00 00 03 DB 70 75 73 68 20 74 6F 20 74 61 6C 6B ....push to talk > > we get big endian, that can be managed on the server side with > htonl,htons. > Thanks! > If you want to use different endianness: unsigned :type, 32, :endian => :native # little endian, if on x86 unsigned :type, 32, :endian => :little # force little endian Big-endian is only the default because many network protocols use it. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407