public function flushReport($auth, $report)
 {
     if (is_null($auth) || is_null($report)) {
         if ($this->_verbose > 0) {
             error_log("Auth or report not set.");
         }
         return null;
     }
     if ($this->_verbose >= 3) {
         var_dump($report);
     }
     $content = json_encode($report);
     $content = gzencode($content);
     $header = "Host: " . $this->_host . "\r\n";
     $header .= "User-Agent: LightStep-PHP\r\n";
     $header .= "LightStep-Access-Token: " . $auth->access_token . "\r\n";
     $header .= "Content-Type: application/json\r\n";
     $header .= "Content-Length: " . strlen($content) . "\r\n";
     $header .= "Content-Encoding: gzip\r\n";
     $header .= "Connection: keep-alive\r\n\r\n";
     // Use a persistent connection when possible
     $fp = @pfsockopen($this->_host, $this->_port, $errno, $errstr);
     if (!$fp) {
         if ($this->_verbose > 0) {
             error_log($errstr);
         }
         return null;
     }
     @fwrite($fp, "POST /api/v0/reports HTTP/1.1\r\n");
     @fwrite($fp, $header . $content);
     @fflush($fp);
     @fclose($fp);
     return null;
 }
Ejemplo n.º 2
0
 protected function _checkConnection($host, $port)
 {
     $fp = @pfsockopen($host, $port);
     if (!$fp) {
         $this->markTestSkipped('Connection to ' . $host . ':' . $port . ' failed');
     }
 }
Ejemplo n.º 3
0
 protected function connectSocket()
 {
     if (filter_var($this->host, FILTER_VALIDATE_IP)) {
         $ip = $this->host;
     } else {
         $ip = gethostbyname($this->host);
         if ($ip == $this->host) {
             throw new MongoConnectionException(sprintf('couldn\'t get host info for %s', $this->host));
         }
     }
     // For some reason, PHP doesn't currently allow resources opened with
     // fsockopen/pfsockopen to be used with socket_* functions, but HHVM does.
     if (defined('HHVM_VERSION')) {
         $this->socket = pfsockopen($ip, $this->port, $errno, $errstr, $this->connectTimeoutMS / 1000);
         if ($this->socket === false) {
             $this->socket = null;
             throw new MongoConnectionException(sprintf("unable to connect to {$ip}:{$this->port} because: %s", "{$errstr} ({$errno})"));
         }
     } else {
         $this->socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname("tcp"));
         if (!$this->socket) {
             throw new MongoConnectionException(sprintf('error creating socket: %s', socket_strerror(socket_last_error())));
         }
         $connected = socket_connect($this->socket, $ip, $this->port);
         if (!$connected) {
             throw new MongoConnectionException(sprintf("unable to connect to {$ip}:{$this->port} because: %s", socket_strerror(socket_last_error())));
         }
     }
 }
Ejemplo n.º 4
0
 function do_post_request($url, $data, $optional_headers = null)
 {
     $start = strpos($url, '//') + 2;
     $end = strpos($url, '/', $start);
     $host = substr($url, $start, $end - $start);
     $domain = substr($url, $end);
     $fp = pfsockopen($host, 80);
     if (!$fp) {
         return null;
     }
     fputs($fp, "POST {$domain} HTTP/1.1\n");
     fputs($fp, "Host: {$host}\n");
     if ($optional_headers) {
         fputs($fp, $optional_headers);
     }
     fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
     fputs($fp, "Content-length: " . strlen($data) . "\n\n");
     fputs($fp, "{$data}\n\n");
     $response = "";
     while (!feof($fp)) {
         $response .= fgets($fp, 1024);
     }
     fclose($fp);
     return $response;
     /*
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url . $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
     curl_setopt($ch, CURLOPT_TIMEOUT, 2);
     $response = curl_exec($ch);
     curl_close($ch);
     */
 }
Ejemplo n.º 5
0
 private function createSocket()
 {
     if ($this->socket_failed) {
         return false;
     }
     $protocol = $this->ssl() ? "ssl" : "tcp";
     $host = $this->options["host"];
     $port = $this->ssl() ? 443 : 80;
     $timeout = $this->options["timeout"];
     try {
         # Open our socket to the API Server.
         # Since we're try catch'ing prevent PHP logs.
         $socket = @pfsockopen($protocol . "://" . $host, $port, $errno, $errstr, $timeout);
         # If we couldn't open the socket, handle the error.
         if ($errno != 0) {
             $this->handleError($errno, $errstr);
             $this->socket_failed = true;
             return false;
         }
         return $socket;
     } catch (Exception $e) {
         $this->handleError($e->getCode(), $e->getMessage());
         $this->socket_failed = true;
         return false;
     }
 }
Ejemplo n.º 6
0
 public function psocket(string $host, int $port = -1, int $timeout = 60)
 {
     $socket = pfsockopen($this->cleanHttp($host), $port, $errno, $errstr, $timeout);
     if (!empty($errno)) {
         throw new SocketException($errno . '-' . $errstr);
     }
     return $socket;
 }
Ejemplo n.º 7
0
 public function fsockopen($hostname, $port = -1, &$errno = null, &$errstr = null, $timeout = null, $persistent = false)
 {
     if ($persistent) {
         return @pfsockopen($hostname, $port, $errno, $errstr, $timeout);
     } else {
         return @fsockopen($hostname, $port, $errno, $errstr, $timeout);
     }
 }
Ejemplo n.º 8
0
 /**
  * Opens a persistant socket connection
  */
 public function __construct($config)
 {
     // Connect
     if (!(static::$socket = pfsockopen($config['ip'], $config['port'], $errno, $errstr, 30))) {
         throw new Exception("Unable to connect to " . $config['ip'] . ' on port ' . $config['port']);
     }
     // FuelPHP logger
     @\Log::debug('SOCKET OPEN');
 }
Ejemplo n.º 9
0
 public function _connect()
 {
     $this->_socket = @pfsockopen($this->_host, $this->_port, $errno, $errstr, $this->_timeout);
     if ($this->_socket === false) {
         return new PHPTCP_Error($errno, $errstr);
     }
     stream_set_write_buffer($this->_socket, 0);
     socket_set_timeout($this->_socket, $this->_timeout);
 }
Ejemplo n.º 10
0
 /**
  * connect to statsd service
  */
 protected function connect()
 {
     $errno = null;
     $errstr = null;
     if ($this->_persistent) {
         $this->_socket = pfsockopen(sprintf("udp://%s", $this->_host), $this->_port, $errno, $errstr, $this->_timeout);
     } else {
         $this->_socket = fsockopen(sprintf("udp://%s", $this->_host), $this->_port, $errno, $errstr, $this->_timeout);
     }
 }
Ejemplo n.º 11
0
 function jfsockopen($hostname, $port, $errno, $errstr, $timeout)
 {
     $fp = false;
     if (function_exists('fsockopen')) {
         @($fp = fsockopen($hostname, $port, $errno, $errstr, $timeout));
     } elseif (function_exists('pfsockopen')) {
         @($fp = pfsockopen($hostname, $port, $errno, $errstr, $timeout));
     }
     return $fp;
 }
Ejemplo n.º 12
0
 /**
  *
  * @throws StreamException
  * @return resource
  */
 protected function _connect()
 {
     if (!empty($this->_stream)) {
         return $this->_stream;
     }
     $this->_stream = $this->_options['persistent'] ? pfsockopen($this->_options['host'], $this->_options['port'], $errorCode, $errorMessage, $this->_options['connectTimeout']) : fsockopen($this->_options['host'], $this->_options['port'], $errorCode, $errorMessage, $this->_options['connectTimeout']);
     if ($this->_stream === false) {
         throw new StreamException($errorMessage, $errorCode);
     }
     stream_set_timeout($this->_stream, $this->_options['timeout']);
 }
Ejemplo n.º 13
0
 /**
  * @param string $host
  * @param int $port
  * @param int|null $timeout
  * @param bool $persistent
  */
 protected function connect($host, $port, $timeout, $persistent)
 {
     $errorNumber = null;
     $errorMessage = null;
     $url = sprintf("tcp://%s", $host);
     if ($persistent) {
         $this->socket = pfsockopen($url, $port, $errorNumber, $errorMessage, $timeout);
     } else {
         $this->socket = fsockopen($url, $port, $errorNumber, $errorMessage, $timeout);
     }
 }
Ejemplo n.º 14
0
 function post($data, $url = '')
 {
     if ($url == '') {
         $url = $this->rest_endpoint;
     }
     if (!preg_match("|https://(.*?)(/.*)|", $url, $matches)) {
         die('There was some problem figuring out your endpoint');
     }
     if (function_exists('curl_init')) {
         $curl = curl_init($url);
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         $response = curl_exec($curl);
         curl_close($curl);
     } else {
         foreach ($data as $key => $value) {
             $data[$key] = $key . '=' . urlencode($value);
         }
         $data = implode('&', $data);
         $fp = @pfsockopen($matches[1], 80);
         if (!$fp) {
             die('Could not connect to the web service');
         }
         fputs($fp, 'POST ' . $matches[2] . " HTTP/1.1\n");
         fputs($fp, 'Host: ' . $matches[1] . "\n");
         fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
         fputs($fp, "Content-length: " . strlen($data) . "\n");
         fputs($fp, "Connection: close\r\n\r\n");
         fputs($fp, $data . "\n\n");
         $response = "";
         while (!feof($fp)) {
             $response .= fgets($fp, 1024);
         }
         fclose($fp);
         $chunked = false;
         $http_status = trim(substr($response, 0, strpos($response, "\n")));
         if ($http_status != 'HTTP/1.1 200 OK') {
             die('The web service endpoint returned a "' . $http_status . '" response');
         }
         if (strpos($response, 'Transfer-Encoding: chunked') !== false) {
             $temp = trim(strstr($response, "\r\n\r\n"));
             $response = '';
             $length = trim(substr($temp, 0, strpos($temp, "\r")));
             while (trim($temp) != "0" && ($length = trim(substr($temp, 0, strpos($temp, "\r")))) != "0") {
                 $response .= trim(substr($temp, strlen($length) + 2, hexdec($length)));
                 $temp = trim(substr($temp, strlen($length) + 2 + hexdec($length)));
             }
         } elseif (strpos($response, 'HTTP/1.1 200 OK') !== false) {
             $response = trim(strstr($response, "\r\n\r\n"));
         }
     }
     return $response;
 }
Ejemplo n.º 15
0
 public function connect($host)
 {
     if (!$this->socket) {
         $this->socket = @pfsockopen($host, $this->defaultPort, $errno, $errstr);
         if (!$this->socket || $errno > 0) {
             return false;
         } else {
             return $this;
         }
     }
     return $this;
 }
Ejemplo n.º 16
0
function pfsockopen_random_port(&$fsock, $address)
{
    $fsock = false;
    for ($i = 0; $i < 100; $i++) {
        $port = get_random_port();
        $fsock = @pfsockopen($address, $port);
        if ($fsock !== false) {
            return $port;
        }
    }
    return 0;
}
Ejemplo n.º 17
0
 function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15)
 {
     $fp = '';
     if (function_exists('fsockopen')) {
         $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout);
     } elseif (function_exists('pfsockopen')) {
         $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout);
     } elseif (function_exists('stream_socket_client')) {
         $fp = @stream_socket_client($hostname . ':' . $port, $errno, $errstr, $timeout);
     }
     return $fp;
 }
Ejemplo n.º 18
0
 private function create_socket()
 {
     try {
         $socket = pfsockopen("ssl://typekit.com", 443, $errno, $errstr, $this->timeout);
         if ($errno != 0) {
             return false;
         }
         return $socket;
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 19
0
 public function __construct($hostname = "localhost", $port = "2088")
 {
     //        if (!is_array(self::$_connections)) {
     //            self::$_connections = array();
     //        }
     //        if (empty(self::$_connections[self::$_currentConnIndex])) {
     //            self::$_connections[self::$_currentConnIndex] = fsockopen($hostname, $port);
     //        }
     //        self::$_currentConnIndex = self::$_currentConnIndex % 4;
     //        $connection = self::$_connections[self::$_currentConnIndex];
     //        self::$_currentConnIndex++;
     //        $this->_conn = $connection;
     $this->_conn = pfsockopen($hostname, $port);
 }
Ejemplo n.º 20
0
 /**
  * @param string $hostname
  * @param int    $port    [optional]
  * @param int    $errno   [optional]
  * @param string $errstr  [optional]
  * @param float  $timeout [optional]
  *
  * @return resource
  */
 public function open($hostname, $port = null, &$errno = null, &$errstr = null, $timeout = null)
 {
     switch (func_num_args()) {
         case 1:
             return pfsockopen($hostname);
         case 2:
             return pfsockopen($hostname, $port);
         case 3:
             return pfsockopen($hostname, $port, $errno);
         case 4:
             return pfsockopen($hostname, $port, $errno, $errstr);
         default:
             return pfsockopen($hostname, $port, $errno, $errstr, $timeout);
     }
 }
Ejemplo n.º 21
0
 function http_gpc_send($loc, $cookie = "", $postdata = "")
 {
     //overload function polymorphism between gets and posts
     $url = parse_url($loc);
     if (!isset($url['port'])) {
         $url['port'] = 80;
     }
     //$ua=$_SERVER['HTTP_USER_AGENT'];
     $ua = 'GPC/.01';
     if ($this->proxy_ip != '' && $this->proxy_port != '') {
         $fp = pfsockopen($this->proxy_ip, $this->proxy_port, &$errno, &$errstr, 120);
         $url['path'] = $url['host'] . ':' . $url['port'] . $url['path'];
     } else {
         $fp = fsockopen($url['host'], $url['port'], &$errno, &$errstr, 120);
     }
     if (!$fp) {
         print "{$errstr} ({$errno})<br>\nn";
     } else {
         if ($postdata == '') {
             fputs($fp, "GET " . $url['path'] . "?" . $url['query'] . " HTTP/1.1\r\n");
         } else {
             fputs($fp, "POST " . $url['path'] . "?" . $url['query'] . " HTTP/1.1\r\n");
         }
         if ($this->proxy_name != '' && $this->proxy_pass != '') {
             fputs($fp, "Proxy-Authorization: Basic " . base64_encode($this->proxy_name . ":" . $this->proxy_pass) . "\r\n\r\n");
         }
         fputs($fp, "Host: " . $url['host'] . ":" . $url['port'] . "\r\n");
         fputs($fp, "User-Agent: " . $ua . "\r\n");
         fputs($fp, "Accept: text/plain\r\n");
         fputs($fp, "Connection: Close\r\n");
         if ($cookie != '') {
             fputs($fp, "Cookie: " . $cookie . "\r\n");
         }
         if ($postdata != '') {
             $strlength = strlen($postdata);
             fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
             fputs($fp, "Content-length: " . $strlength . "\r\n\r\n");
             fputs($fp, $postdata);
         }
         fputs($fp, "\n\n");
         $output = "";
         while (!feof($fp)) {
             $output .= fgets($fp, 1024);
         }
         fclose($fp);
     }
     return $output;
 }
Ejemplo n.º 22
0
 public function connect()
 {
     if (!$this->_persist || !$this->_conxn) {
         $this->disconnect();
     }
     if ($this->_persist) {
         if ($this->_conxn) {
             return true;
         } else {
             $this->_conxn = @pfsockopen($this->_host, $this->_port);
         }
     } else {
         $this->_conxn = @fsockopen($this->_host, $this->_port);
     }
     return $this->_conxn;
 }
Ejemplo n.º 23
0
 /**
  * 创建连接
  *
  * @return resource
  */
 public function connect()
 {
     if ($this->connection != null) {
         $this->disconnect();
     }
     if ($this->config['persistent'] == true) {
         $tmp = null;
         $this->connection = @pfsockopen($this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
     } else {
         $this->connection = fsockopen($this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']);
     }
     if (!empty($errNum) || !empty($errStr)) {
         $this->error($errStr, $errNum);
     }
     $this->connected = is_resource($this->connection);
     return $this->connected;
 }
Ejemplo n.º 24
0
 function socks5($ip, $port)
 {
     if ($this->socket = pfsockopen($ip, (int) $port, $errno, $errstr)) {
         $buf["send"] = pack("C3", 0x5, 0x1, 0x0);
         fwrite($this->socket, $buf["send"]);
         $buf["recv"] = "";
         while ($buffer = fread($this->socket, 1024)) {
             $buf["recv"] .= $buffer;
         }
         $responce = unpack("Cversion/Cmethod", $buf["recv"]);
         if ($responce["version"] == 0x5 and $responce["method"] == 0x0) {
             return true;
         }
         fclose($this->socket);
     }
     return false;
 }
Ejemplo n.º 25
0
 function connect()
 {
     //if($this->connected==0){
     $this->host = trim($this->host);
     $this->sock = @fsockopen($this->host, $this->port, $this->errno, $this->errmsg, $this->timeout);
     if (!$this->sock) {
         $this->sock = @pfsockopen($this->host, $this->port, $this->errno, $this->errmsg, $this->timeout);
     }
     if ($this->sock > 0) {
         $this->connected = 1;
         stream_set_timeout($this->sock, $this->timeout);
         return 0;
     } else {
         return -1;
     }
     //}
 }
Ejemplo n.º 26
0
 public function send($host, $uri, $body, $port = 443)
 {
     $resource = null;
     $errNum = $errStr = '';
     $openSocket = function () use($host, &$resource, &$errNum, &$errStr, $port) {
         $resource = pfsockopen("ssl://" . $host, $port, $errNum, $errStr, 10);
         return $resource;
     };
     if (!$openSocket()) {
         error_log("Could not send datadog stat. Socket error: {$errStr} ({$errNum}) \n");
         return false;
     } else {
         $sendRequest = function () use($uri, $host, $body, &$resource, $openSocket) {
             $out = "POST {$uri} HTTP/1.1\r\n";
             $out .= "Host: {$host}\r\n";
             $out .= "Accept: application/json\r\n";
             $out .= "Content-Type: application/json\r\n";
             $out .= "Content-Length: " . strlen($body) . "\r\n";
             $out .= "Connection: Close\r\n\r\n";
             $out .= $body . "\r\n\r\n";
             $bytesToWrite = strlen($out);
             $totalBytesWritten = 0;
             while ($totalBytesWritten < $bytesToWrite) {
                 try {
                     $bytes = fwrite($resource, substr($out, $totalBytesWritten));
                     $totalBytesWritten += $bytes;
                 } catch (\Exception $e) {
                     fclose($resource);
                     $openSocket();
                 }
             }
             //                while (!feof($resource)) {
             //                    echo fgets($resource, 128);
             //                }
             return true;
         };
         if ($sendRequest() == false) {
             // reopen socket and try to send again
             fclose($resource);
             $resource = null;
             $openSocket();
             $sendRequest();
         }
         return true;
     }
 }
function PostToHost($url, $post_data_to_send, $wait_for_response = false)
{
    //$url = 'https://www.paypal.com/de/cgi-bin/webscr';
    $timeout = 9;
    $url_parts = parse_url($url);
    $host = $url_parts['host'];
    $path = $url_parts['path'];
    /*
    $query=$url_parts['query'];
    $scheme=$url_parts['scheme'];
    $port=$url_parts['port'];
    $user=$url_parts['user'];
    $pass=$url_parts['pass'];
    $fragment=$url_parts['fragment'];
    */
    if ($_SERVER['HTTP_HOST'] != 'localhost') {
        $use_ssl = !(strpos($url, "https") === false);
    }
    if ($use_ssl) {
        $fp = pfsockopen("ssl://" . $host, 443, $errno, $errstr, $timeout);
    } else {
        $fp = fsockopen($host, 80, $errno, $errstr, $timeout);
    }
    if ($fp) {
        fputs($fp, "POST {$path} HTTP/1.1\r\n");
        fputs($fp, "Host: {$host}\r\n");
        fputs($fp, "Referer: {$referer}\r\n");
        fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
        fputs($fp, "Content-length: " . strlen($post_data_to_send) . "\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        fputs($fp, $post_data_to_send);
        if ($wait_for_response) {
            while (!feof($fp)) {
                $res .= fgets($fp, 128);
            }
            return $res;
        } else {
            echo 'AJAX_NODATA';
        }
        fclose($fp);
    } else {
        include_once DIR_FS_INC . "ajax_error.inc.php";
        ajax_error(sprintf(PAYMENT_PROBLEM, ${$_SESSION}['payment']->title));
    }
}
Ejemplo n.º 28
0
 public function makeCall($sequence)
 {
     $result = '';
     // Open the socket
     // $fp = fsockopen ($this->osrs_host, $this->osrs_port, $errno, $errstr, $this->osrs_portwait);
     $fp = pfsockopen($this->osrs_host, $this->osrs_port, $errno, $errstr, $this->osrs_portwait);
     if (!$fp) {
         trigger_error("oSRS Error - {$errstr} ({$errno})<br />\n");
         // Something went wrong
     } else {
         // Send commands to tucows server
         for ($i = 0; $i < count($sequence); $i++) {
             $servCatch = "";
             // Write the port
             $writeStr = $sequence[$i] . "\r\n";
             $fwrite = fwrite($fp, $writeStr);
             if (!$fwrite) {
                 trigger_error("oSRS - Mail System Write Error, please check if your network allows connection to the server.");
             }
             $dotStr = ".\r\n";
             $fwrite = fwrite($fp, $dotStr);
             if (!$fwrite) {
                 trigger_error("oSRS - Mail System Write Error, please check if your network allows connection to the server.");
             }
             // read the port rightaway
             // Last line of command has be done with different type of reading
             if ($i == count($sequence) - 1) {
                 // Loop until End of transmission
                 while (!feof($fp)) {
                     $servCatch .= fgets($fp, 128);
                 }
             } else {
                 // Plain buffer read with big data packet
                 $servCatch .= fread($fp, 8192);
             }
             // Possible parsing and additional validation will be here
             // If error accours in the communication than the script should quit rightaway
             // $servCatch
             $result .= $servCatch;
         }
     }
     //Close the socket
     fclose($fp);
     return $result;
 }
Ejemplo n.º 29
0
 /**
  * Push a raw payload onto the queue.
  *
  * @param  string  $payload
  * @param  string  $queue
  * @param  array   $options
  * @return mixed
  */
 public function pushRaw($payload, $queue = null, array $options = array())
 {
     $host = array_get($this->config, 'url');
     $host = $path = str_replace(array('https://', 'http://'), array('ssl://', ''), $host);
     $host = explode('/', $host);
     $host = $host[0];
     $port = false !== strstr($host, 'ssl://') ? 443 : 80;
     $path = str_replace($host, '', $path);
     $path = empty($path) ? '/' : $path;
     $path .= false === strstr($path, '?') ? '?' : '&';
     $path .= 'msgid=' . microtime(true);
     $body = array_get($this->config, 'method', 'GET') . " {$path} HTTP/1.0\n";
     $body .= "Host: {$host}\n";
     $body .= "Content-Type: application/x-www-form-urlencoded\n";
     $body .= "Content-Length: " . strlen($payload) . "\n\n";
     $body .= $payload;
     $socket = pfsockopen($host, $port, $errno, $errstr, 5);
     fwrite($socket, $body);
     fclose($socket);
     return 0;
 }
Ejemplo n.º 30
0
 /**
  * Sockey 版本
  * @param $path
  * @param $data
  * @return array
  */
 private function postBySocket($path, $data)
 {
     $content = "";
     $post_string = http_build_query($data);
     if (function_exists('fsockopen')) {
         $fp = @fsockopen($this->_host, $this->_port, $errno, $err, $this->_timeout);
     } elseif (function_exists('pfsockopen')) {
         $fp = @pfsockopen($this->_host, $this->_port, $errno, $err, $this->_timeout);
     }
     if ($fp) {
         fwrite($fp, "POST {$path} HTTP/1.0\r\n");
         fwrite($fp, "Host: {$this->_host}:{$this->_port}\r\n");
         fwrite($fp, "Content-type: application/x-www-form-urlencoded\r\n");
         fwrite($fp, "Content-length: " . strlen($post_string) . "\r\n");
         fwrite($fp, "User-Agent : Yuc Media Agent" . "\r\n");
         fwrite($fp, "Accept:*/*\r\n");
         fwrite($fp, "Connection: close\r\n\r\n");
         fwrite($fp, $post_string);
         $atStart = TRUE;
         while (!feof($fp)) {
             $line = fgets($fp, 1028);
             if ($atStart) {
                 $atStart = FALSE;
                 if (!preg_match('/HTTP\\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
                     return FALSE;
                 }
                 $this->_status = $m[2];
                 continue;
             }
             $content .= $line;
         }
         fclose($fp);
     }
     $content = preg_replace("/^.*\r\n\r\n/Us", '', $content);
     $this->_content = trim($content);
     return $content;
 }