Lines Matching refs:socket

254         $socket = null;
257 $socket = self::$connections[$connectionId];
259 if (is_null($socket) || feof($socket)) {
262 $socket = @fsockopen($server,$port,$errno, $errstr, $this->timeout);
263 if (!$socket){
271 if($this->ssltunnel($socket, $request_url)){
280 fclose($socket);
286 self::$connections[$connectionId] = $socket;
303 stream_set_blocking($socket, 0);
313 $this->sendData($socket, $request, 'request');
318 $r_line = $this->readLine($socket, 'headers');
368 fclose($socket);
411 while (preg_match('/^[a-zA-Z0-9]?$/',$byte=$this->readData($socket,1,'chunk'))){
417 $this->readLine($socket, 'chunk'); // readtrailing \n
429 $r_body .= $this->readData($socket, $chunk_size, 'chunk');
430 $this->readData($socket, 2, 'chunk'); // read trailing \r\n
451 … $r_body = $this->readData($socket, $length, 'response (content-length limited)', true);
453 …$r_body = $this->readData($socket, $this->max_bodysize+1, 'response (content-length limited)', tru…
458 while (!feof($socket)) {
459 $r_body .= $this->readData($socket, 4096, 'response (unlimited)', true);
479 fclose($socket);
486 fclose($socket);
518 protected function ssltunnel(&$socket, &$requesturl){ argument
533 $this->sendData($socket, $request, 'SSL Tunnel CONNECT');
538 $r_line = $this->readLine($socket, 'headers');
545 stream_context_set_option($socket, 'ssl', 'peer_name', $requestinfo['host']);
556 if (@stream_socket_enable_crypto($socket, true, $cryptoMethod)) {
573 * @param resource $socket An open socket handle
580 protected function sendData($socket, $data, $message) { argument
589 if(feof($socket))
594 $sel_w = array($socket);
603 $nbytes = fwrite($socket, substr($data,$written,4096));
616 * @param resource $socket An open socket handle in non-blocking mode
625 protected function readData($socket, $nbytes, $message, $ignore_eof = false) { argument
636 if(feof($socket)) {
644 $sel_r = array($socket);
653 $bytes = fread($socket, $to_read);
668 * @param resource $socket An open socket handle in non-blocking mode
675 protected function readLine($socket, $message) { argument
683 if(feof($socket))
687 $sel_r = array($socket);
696 $r_data = fgets($socket, 1024);