|
From: <php...@li...> - 2010-02-07 07:29:57
|
Hi Peter, > The apache server sends garbage if you send http 1.0 but expect http > 1.1. are we talking about this apache feature which can stream bytes to the client? This feature is quite useful on C level, you can simply read() the bytes as apache generates them. But it is difficult to handle in PHP or Bea WebLogic for example, because their network implementations use a buffer which reads data eagerly. If the PHP network buffer contains 4 bytes and fread() requests 20 bytes, PHP tries to read 16 bytes from the network, instead of simply returning the 4 bytes available so far. I don't know why PHP and other JEE servers implement their network buffers this way. It might be more efficient for normal HTTP connections, but it is bad for data packets which don't have an explicit length; in PHP you must call fread($sock, 1), if you don't want to run into a dead lock. Or you must unblock the stream and call stream_select() for each packet. Very low tech... Regards, Jost Bökemeier |