You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@gonzo.ben.algroup.co.uk> on 1996/04/01 17:34:28 UTC

Re: HostAlias...

> 
> 
> On the subject of write() and fwrite(), one catch
> might be that the first one returns -1 on a fail whereas the
> latter returns 0 I think, so a loop like
> 
>       while(n && !r->connection->aborted) {
>             w=fwrite(&buf[o],sizeof(char),n,c->client);
>             n-=w;
>             o+=w;
>             };
> 
> goes OK, but this goes bang

No it doesn't ... you need something more like:

	 do
             {
             w=fwrite(&buf[o],sizeof(char),n,c->client);
             n-=w;
             o+=w;
             }
         while(w && n && !r->connection->aborted);



> 
>       while(n && !r->connection->aborted) {
>             w=write(....; /* returns -1 on a fail ! */
>             n-=w;
>             o+=w;
> 	    };
> 
> I got caught by that recently.
> 

And in this case:

	 do
             {
             w=write(...
             n-=w;
             o+=w;
             }
         while(w > 0 && n && !r->connection->aborted);

Cheers,

Ben.

> Dw.

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.