On Fri, Jul 11, 2003, Damon Hastings wrote:

> This is probably a stupid question, but how do you do line-oriented blocking
> socket reads in Pth?  There's a pth_read() which I assume blocks until a
> specified number of bytes (or eof) are received -- but I'm looking for
> something like pth_gets() to block until a newline is received.  I don't
> think you could even write a simple webserver in Pth without such a
> function, though you could of course implement it yourself via a
> non-blocking pth_read in a loop.  I'll implement it myself if need be,
> though I would rather trust someone else's code, as I've never used Pth
> before and there are lots of tricky error conditions in socket programming.
>
> The documentation at http://www.gnu.org/software/pth/pth-manual.html
> includes a simple output-only server as a code example -- is there an
> input/output example somewhere?

See the file test_common.c in the Pth source tree. It provides a
pth_readline() function (just a small but sufficient buffered wrapper
around pth_read()) which should do exactly what you want.

                                       Ralf S. Engelschall
                                       [EMAIL PROTECTED]
                                       www.engelschall.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