Re: AW: Net_Server interface (bug?)

From: Date: Tue, 11 Nov 2003 07:35:11 +0000
Subject: Re: AW: Net_Server interface (bug?)
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-23414@lists.php.net to get a copy of this message
> There has to be a character that can be used to mark the end of the > data, otherwise you'll end up in an infinite loop :-( There should be a such character... If I've to write an HTTP client, surely I put a /n at the end of the request stream, Netscape guys too, but MS does not. Stated that I need a server that accept HTTP post from the very buggy Internet Explorer, I modified the method as follows: function readFromSocket($clientId = 0) { // start with empty string $data = ""; // read data from socket while($buf = socket_read($this->clientFD[$clientId], $this->readBufferSize)) { $data .= $buf; if ($buf == NULL || strlen($buf) < $this->readBufferSize) { break; } } if ($buf === false) { $this->_sendDebugMessage("Could not read from client ".$clientId." ("..$this->getLastSocketError($this->clientFD[$clientId]).")."); } return $data; } As you can see, no end character is required in this implementation; I simply let socket_read to read blocks of data, until the last block is reached the block size is surely == readBufferSize. When the last block is reached, there're two cases: 1) the remaining block is smaller than readBufferSize; 2) the remaining block is EXACTLY readBufferSize. With my modified method readFromSocket() the 1) case is OK; to be honest, I never tried the case 2), but it's not so frequent, is it? Bye, Luca Ing. Luca Mariano ------------------------------- --------- - email: luca.mariano@email.it - cell: 347/56.03.614 - web: http://www.lucamariano.it ------------------------------- --------- -- Email.it, the professional e-mail, gratis per te: http://www.email.it/f Sponsor: Conto Arancio. Zero spese, stessa banca, più interessi. Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=657&d=11-11

« previous php.pear.dev (#23414) next »