cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

fsockopen replacment

From: StephenB <sb1304_at_hotmail.com>
Date: Sun, 27 Nov 2005 20:21:15 -0000

Hi

I'm having a number of problems translating an fsockopen call to a remote server. The server is a domain availability checker running on port2043 and tied to the calling servers IP address.

The following fsockopen code works fine...

 $dac = fsockopen("dac.nic.uk", 2043, $errno, $errstr, 10);
 if (!$dac) {
      echo "$errstr ($errno)<br />\n";
      exit;
 } else {
    //do stuff
    fputs($dac, "domain.co.uk\r\n");
    $resp = fgets($dac,128);
 }

echo $resp

but translating this to curl...
<?php
$curlPost = array ("domain.co.uk\r\n");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://dac.nic.uk');
curl_setopt($ch, CURLOPT_PORT, 2043);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt ($ch, CURLOPT_HTTPHEADER, $curlPost);
$data = curl_exec($ch);
print_r(curl_getinfo($ch));
echo "\n\ncURL error number:" .curl_errno($ch);
echo "\n\ncURL error:" . curl_error($ch);
curl_close($ch);

echo "$data";
?>

gives... error7

Array ( [url] => http://dac.nic.uk [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 4.6E-05 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 0 [redirect_time] => 0 ) cURL error number:7 cURL error:Connect failed; Operation now in progress

Any ideas? I've tried post and get the same error.

Stephen

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-11-27