On Feb 1, 2006, at 11:11 AM, Mark Volkmann wrote:
>> 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?

I'd like to put a plug in for the book: Advanced Programming in the Unix
Environment (APUE) by Rich Stevens.  (Disclaimer: I worked with and  
co-authored
a book with Rich).  If you are doing lots of network programming then  
you
want to read Unix Network Programming also.

Many of the IO and networking questions that pop up on this list are
not really Ruby questions but questions about the Unix IO model, socket
programming and/or Unix OS concepts (or Posix if you prefer).  If you  
are
doing lots of programming of that type it will really help to understand
the underlying OS abstractions.  Understanding the Posix OS model will
also help you write more portable code that works correctly on Linux,  
Mac OS X,
Windows, and so on.


Gary Wright