Lines Matching refs:socket
249 $socket = null;
252 $socket = self::$connections[$connectionId];
254 if (is_null($socket) || feof($socket)) {
257 $socket = @fsockopen($server, $port, $errno, $errstr, $this->timeout);
258 if (!$socket) {
266 if ($this->ssltunnel($socket, $request_url)) {
275 fclose($socket);
281 self::$connections[$connectionId] = $socket;
298 stream_set_blocking($socket, 0);
308 $this->sendData($socket, $request, 'request');
313 $r_line = $this->readLine($socket, 'headers');
362 fclose($socket);
405 … while (preg_match('/^[a-zA-Z0-9]?$/', $byte = $this->readData($socket, 1, 'chunk'))) {
411 $this->readLine($socket, 'chunk'); // readtrailing \n
423 $r_body .= $this->readData($socket, $chunk_size, 'chunk');
424 $this->readData($socket, 2, 'chunk'); // read trailing \r\n
448 … $r_body = $this->readData($socket, $length, 'response (content-length limited)', true);
450 …$r_body = $this->readData($socket, $this->max_bodysize + 1, 'response (content-length limited)', t…
455 while (!feof($socket)) {
456 $r_body .= $this->readData($socket, 4096, 'response (unlimited)', true);
475 fclose($socket);
484 fclose($socket);
518 protected function ssltunnel(&$socket, &$requesturl) argument
535 $this->sendData($socket, $request, 'SSL Tunnel CONNECT');
540 $r_line = $this->readLine($socket, 'headers');
547 stream_context_set_option($socket, 'ssl', 'peer_name', $requestinfo['host']);
558 if (@stream_socket_enable_crypto($socket, true, $cryptoMethod)) {
576 * @param resource $socket An open socket handle
583 protected function sendData($socket, $data, $message) argument
593 if (feof($socket))
598 $sel_w = [$socket];
607 $nbytes = fwrite($socket, substr($data, $written, 4096));
620 * @param resource $socket An open socket handle in non-blocking mode
629 protected function readData($socket, $nbytes, $message, $ignore_eof = false) argument
647 if (feof($socket)) {
655 $sel_r = [$socket];
664 $bytes = fread($socket, $to_read);
679 * @param resource $socket An open socket handle in non-blocking mode
686 protected function readLine($socket, $message) argument
696 if (feof($socket))
700 $sel_r = [$socket];
709 $r_data = fgets($socket, 1024);