--- "C. Scott Ananian" <[EMAIL PROTECTED]> wrote:
> On Mon, 14 Jul 2003, Damon Hastings wrote:
> 
> > Yeah, I guess my explanation was a little spotty.  :->  What I want is
> for a
> > thread to block only until a newline is received on the socket it's
> reading
> > from.  Suppose the socket receives the 12 bytes "hello world\n".  That
> has a
> > newline and so I would want pth_readline() to return immediately with
> the
> > output "hello world\n".  But if pth_readline() does a blocking 1024-byte
> > read on the socket, it will find only 12 bytes available and will thus
> > block.  Furthermore, the remote host will not send any more bytes
> because
> > it's waiting for us to respond, and so pth_readline() will time out, or
> > never return.
> 
> I don't think there's any way in a POSIX/UNIX operating system to block
> until *all of* 1024 bytes have been read from a file descriptor.
> The blocking 'read' system call returns as soon as *any* bytes have been
> read, not putting more than a certain number in the buffer you provide.
> Under POSIX semantics, you *always* have to do a loop in order to
> ensure your buffer is filled.

Ah, yes, I should have known that.  Thanks for straightening out my
confusion.  pth_readline() does indeed do exactly what I want.  :)

Damon

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
Development Site                      http://www.ossp.org/pkg/lib/pth/
Distribution Files                          ftp://ftp.gnu.org/gnu/pth/
Distribution Snapshots                 ftp://ftp.ossp.org/pkg/lib/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to