On 2/1/06, Joel VanderWerf <vjoel / path.berkeley.edu> wrote:
> Mark Volkmann wrote:
> ...
> > require 'socket'
> >
> > # Create socket.
> > host, port = 'localhost', 1919
> > socket = TCPSocket.new(host, port)
> >
> > # Send request message.
> > binary_string = [19, 10, 8].pack('N*')
> > socket.puts binary_string
>
> You want to avoid using gets/puts with binary strings. Those functions
> are for text, and will detect/insert line ends. In fact, 10 is the same
> as a \n character, so that's probably where it's choking.

What do you recommend I use instead of gets and puts?
If I use write, will I need to also call flush?
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?

--
R. Mark Volkmann
Partner, Object Computing, Inc.