From: Johan Dahl Date: 2001-07-10T08:10:26+09:00 Subject: [ruby-talk:17563] Re: writing arbitrary data to a socket >Continuing my investigations into my Ruby network hardware emulator, >is there a >reasonable way to write essentially arbitrary data to a socket? >What I want to >be able to do is write data consisting of something like the following: > >typedef struct all_thing { > uint32_t a; > uint8_t b; > uint8_t c; > int8_t d; > uint8_t e; > uint32_t f; > uint64_t g; > char_t data[0]; >} thing; > >where the final member is an arbitrarily long sequence of characters. > >Do I need to convert my data to a string of ASCII characters in order to write >this struct to a socket? > Hi Use the methods described on these pages to pack arrays and uppack strings (of binary data( http://www.rubycentral.com/book/ref_c_string.html#unpack http://www.rubycentral.com/book/ref_c_array.html#pack With regards, Johan Dahl >__________________________________________________ >Do You Yahoo!? >Get personalized email addresses from Yahoo! Mail >http://personal.mail.yahoo.com/ -- Johan Dahl, Research Engineer Department of Linguistics and Phonetics, Lund University Address: Helgonabacken 12, 223 62 Lund, SWEDEN Tel: +46-(0)46-2228443 Fax: +46-(0)46-2224210 E-mail: mailto:Johan.Dahl@ling.lu.se WWW: http://www.ling.lu.se/persons/Johan/