From: Marcin 'Qrczak' Kowalczyk Date: 2003-05-12T03:38:24+09:00 Subject: Re: disable buffering on sockets Dnia �ro 7. maja 2003 15:37, Brian Candler napisa�: > > I know, but when I'm using read instead of gets, read returns > > all the strings when I close the socket because buffering is enabled. You can't expect that the reader will see the data chunked the same way as they were written. Socket is a bidirectional stream of bytes. If you want to introduce some structure of packets inside the stream, you must arrange it explicitly in the data format. Two writes in a row are equivalent to one write, they can't be distinguished on the other side! > That is, if you call the Unix read() function on a socket, and pass in a > memory buffer of (say) 4096 bytes, it will block until either 4096 bytes > have been read, or until the socket has been closed. No, it will block until any amount > 0 and <= 4096 is available, and return that many. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/