From: cremes.devlist@... Date: 2006-02-02T02:04:02+09:00 Subject: Re: IO and non-strings On Feb 1, 2006, at 10:31 AM, ara.t.howard@noaa.gov wrote: > On Thu, 2 Feb 2006, Mark Volkmann wrote: > >> On 2/1/06, Joel VanderWerf wrote: >> [snip] >> Will I have to first send a number to the server that indicates >> the number >> of bytes I'm going to send next so it will know how many to read? > > that certainly makes it easier in some cases. be careful about the > length of > the lenght though; for instance, if you decide to send something like > 'length:data' to the client then > > 42:foobar # length length == 2 > 4242:foobar # length length == 4 > > might want the client to read chars, based on return value of > select, into a > re-sizeable buf until ':' is seen and then convert to int to do a > read(n). If you want a general mechanism for doing this type of work between Ruby and Other Languages, use NetStrings [1]. If it's Ruby to Ruby, drb is a great choice. (Oh, there is also a Ruby NetStrings class [2] but I can't vouch for its correctness.) cr [1] http://cr.yp.to/proto/netstrings.txt [2] http://raa.ruby-lang.org/project/djb-netstrings/