Re: ap_rwrite
Chris, Thanks for the info. I assume that ap_rwrite is writing directly to the client which you mention is bad. What is the preferred method and why is the ap_rwrite not preferred? Pardon me, I'm a newb. Thanks, Mike On Thu, May 29, 2008 at 4:52 PM, Chris Kukuchka <[EMAIL PROTECTED]> wrote: > Mike O'Leary wrote: > >> I was just wondering if the ap_rwrite call could return some value less >> than the >> number of bytes requested to be written. I wanted to know if I need to >> put >> a loop around all of my ap_rwrite calls to verify that all the data is >> sent. >> > Mike, > > In answer to your question, yes, a loop is in order. Something like this: > > while (n_bytes > 0) > { > int n = (ap_rwrite (data, n_bytes, r)); > if (n < 0) >{ > /* error writing to client */ >} > n_bytes -= n; > data += n; > } > > Further, keep in mind if you are writing an Apache 2 module, you should > *not* be writing directly to the client. Also, there may be a more specific > mailing list available for questions regarding the ap* utilities. > > Chris Kukuchka > Sequoia Group, Inc. > > > >
Re: ap_rwrite
Hello Mike. Two notes on your topic. 1.- In httpd.h there is a constant called MAX_STRING_LEN . Maybe is playing some role here. Did you notice if buffer printing gets cut just when exceeds the number of bytes defined in MAX_STRING_LEN ? 2.- For string printing, I use ap_rputs() http://httpd.apache.org/dev/apidoc/apidoc_ap_rputs.html Not based in any special reason. Simply it is the funcion I saw on some tutorials and I use it. Test it. I always use it for printing short strings, but maybe is useful also in your case. Samuel Mike O'Leary wrote: Hello, I am writing an Apache module using Apache 2.2.3 and, from what I understand, the sockets are non-blocking. My questions is about ap_rwrite having the signature below: AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); Is it possible that ap_rwrite returns some value less than nbyte, but not -1? This would mean that I would need to loop, passing some byte offset into buf and reducing nbyte until all of the content was sent. If it is not possible for ap_rwrite to return some value less than nbyte other than -1, is there some internal mechanism that is looking to enforce a specific transfer rate and will time out and return -1 from ap_rwrite if this rate is not achieved? If this is not the case, then aren't the sockets blocking? Thanks in advance! -Mike