sockets - PHP socket_recv() does not receive the entire response from the server. -
i'm trying receive http response using socket_recv. i'm having trouble responses larger 5000 bytes. stops receiving; without throwing errors; @ 7000 bytes though content-length says response larger (25000 bytes). i'm doing wrong or php sockets unstable?
here's relevant part of code:
while((socket_recv($this->socket, $buf, 1024, msg_waitall)) > 0){ $this->fullresponse .= $buf; } if(!$this->fullresponse){ $errno = socket_last_error(); $errmsg = socket_strerror($errno); echo $this->state = "{$errno} {$errmsg}"; return; }
php sockets ignore content-length headers, because in http response section, , sockets work on lower level. trying http resources? use curl: http://php.net/manual/en/book.curl.php, or if need file that: file_get_contents("http: //www. example.com/ somefile.ext"), work allow_url_fopen must true. found socket_recv comments section on php.net: http://www.php.net/manual/de/function.socket-recv.php#47789
Comments
Post a Comment