From: Joel VanderWerf Date: 2008-09-07T02:38:46+09:00 Subject: Re: Question About TCPServer & TCPSocket classes Robert Klemme wrote: > Just an additional note: if you use Marshal, you can directly read to > and write from the socket without the intermediate String. This is > likely more efficient and also you avoid the issue of not knowing how > long the Marshal sequence is. Good point. I forgot that the output of Marshal records how long the data is, and therefore #load can read the correct number of bytes directly from an io. > And yet another note: just in case you need a solution with > communicating processes where all of them are Ruby applications you can > use DRuby. But I guess at the moment you want to learn about Ruby > socket programming so this is probably just for keeping in the back of > your head. Another possibility, if you are communicating to C code or other languages: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/177704 It's a lib for both C and ruby that uses length fields to make tcp sockets "message oriented" rather than stream oriented. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407