can i replace curl with sockets?

Mark Armendariz nyphp at
Wed Jan 29 15:15:46 EST 2003

To start, I'm new to the list, so hello all.
I'm working on a script that requires cURL, but I'd rather surpass the
need for cURL as it isn't usually installed by default on servers
(namely mine - but other servers I've been on hadn't had it installed
either).  I realize I could try to use the command line cURL, but it's
my understanding that that can be a security issue, and I would just
like to handle it all within the script.
I want to mimic this :
  $curl_holder = curl_init();
  curl_setopt ($curl_holder , CURLOPT_URL, <https://k> '
  curl_setopt ($curl_holder , CURLOPT_HEADER, 0);
  curl_setopt ($curl_holder , CURLOPT_POST, 1);
  curl_setopt ($curl_holder , CURLOPT_POSTFIELDS, $vars);
  curl_setopt ($curl_holder , CURLOPT_RETURNTRANSFER, 1);

  $server_response = curl_exec ($curl_holder );
  curl_close ($curl_holder );
  print $server_response;
I've tried this:
   $vars = 'name=mark&user=enobrev'
   $header = 'POST /track HTTP/1.0' . "\\r\
   $header .= 'Content-type: application/x-www-form-urlencoded' .
   $header .= 'Content-length: ' . strlen($vars) . "\\r\
   $fp = fsockopen('', 443, $error_number,
   if ($fp) {
     fputs($fp, $header . $vars);
    while (!feof($fp)) {
      $response .= fgets($fp, 128);
    print htmlspecialchars($response);
   } else {
    print $error_number . ': ' . $error_sting . ' - could not connect to
' . $url);
And i get a whole bunch of these (which refers to the while line and the
lines within the loop):
Warning: feof(): 2 is not a valid File-Handle resource
The Question
Am I going the right way about this, or is there a better way?  And what
exactly is that error referring to?
Thank you in advance.
Mark Armendariz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the talk mailing list