apr_send() -> how to flush to network?
Hi all, The CONNECT tunnelling part of the mod_proxy code is making direct reads and writes to the network (being a tunnel, other parts of Apache should not be fiddling with the input or output). To send the "HTTP/1.1 200 Connection Established" the code uses apr_send() -> but this data is never flushed, so it never sees the network (a sniff shows nothing over the wire). As a result the connections hangs there and the browser never responds. I cannot find an apr_flush() function - how does apr_send() get fored to write to the network? (Sorry about the dumb questions - I am no sockets guru...) Regards, Graham -- - [EMAIL PROTECTED] "There's a moon over Bourbon Street tonight..."
Re: apr_send() -> how to flush to network?
Graham Leggett <[EMAIL PROTECTED]> writes: > To send the "HTTP/1.1 200 Connection Established" the code uses > apr_send() -> but this data is never flushed, so it never sees the > network (a sniff shows nothing over the wire). As a result the > connections hangs there and the browser never responds. A couple of points... . apr_send() hands the data straight to the TCP/IP stack; it does not buffer data, so there is no need for apr_socket_flush() . if your APR socket has a timeout set or is non-blocking, apr_send() can write fewer bytes than you requested... check the output bytes-written status If no bytes are going to the wire, what is happening in the TCP layer? Can you use netstat to display info about the TCP connection? Maybe there are already bytes in the send buffer and the TCP stack can't accept any more because the other side isn't acknowledging bytes already sent? -- Jeff Trawick | [EMAIL PROTECTED] | PGP public key at web site: http://www.geocities.com/SiliconValley/Park/9289/ Born in Roswell... married an alien...
Re: apr_send() -> how to flush to network?
Jeff Trawick wrote: > . apr_send() hands the data straight to the TCP/IP stack; it does not > buffer data, so there is no need for apr_socket_flush() Ok. > . if your APR socket has a timeout set or is non-blocking, apr_send() > can write fewer bytes than you requested... check the output > bytes-written status > > If no bytes are going to the wire, what is happening in the TCP layer? > Can you use netstat to display info about the TCP connection? Maybe > there are already bytes in the send buffer and the TCP stack can't > accept any more because the other side isn't acknowledging bytes > already sent? A check with netstat shows: Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp0 41 cbs53-01-p87.wc.sa:1777 atlas.thawte.com:https CLOSE which is rather odd - the connection is set up using apr_socket_create(), then opened with apr_connect(), then sent to with apr_send(). Is this the correct sequence of events? Why the CLOSE? Regards, Graham -- - [EMAIL PROTECTED] "There's a moon over Bourbon Street tonight..."
Re: apr_send() -> how to flush to network?
Jeff Trawick wrote: > If no bytes are going to the wire, what is happening in the TCP layer? > Can you use netstat to display info about the TCP connection? Maybe > there are already bytes in the send buffer and the TCP stack can't > accept any more because the other side isn't acknowledging bytes > already sent? As it turned out the code I was working on was way more broken than I thought - many of the sockets were the wrong way round (client and proxy), which meant the entire thing was hosed. Fixed the sockets, the thing started working! :) Regards, Graham -- - [EMAIL PROTECTED] "There's a moon over Bourbon Street tonight..."