curl-and-php
Re: fsockopen replacment
Date: Mon, 28 Nov 2005 09:54:28 -0000
Apologies
curl info: curl 7.12.0 (i686-pc-linux-gnu) libcurl/7.12.0 OpenSSL/0.9.7a
zlib/1.1.4
Protocols: ftp gopher telnet dict ldap http file https ftps
Features: Largefile NTLM SSL libz
Apache/phpinfo: Apache/1.3.33 (Unix) PHP/5.0.4 mod_auth_passthrough/1.8
mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_ssl/2.8.22
OpenSSL/0.9.7a . php --with-curl
The fsockopen example is similar/identical to one used by most people
querying the domain server. The connection opens then waits for the CR/LF
domain name before giving a response.
I've tried it with the port on the url and it seems to connect, but gives
the following error:
Array ( [url] => http://dac.nic.uk:2043 [http_code] => 0 [header_size] => 0
[request_size] => 72 [filetime] => -1 [ssl_verify_result] => 0
[redirect_count] => 0 [total_time] => 5.264429 [namelookup_time] => 0.000121
[connect_time] => 0.074026 [pretransfer_time] => 0.074133 [size_upload] => 0
[size_download] => 82 [speed_download] => 15 [speed_upload] => 0
[download_content_length] => 0 [upload_content_length] => 0
[starttransfer_time] => 3.191224 [redirect_time] => 0 ) cURL error number:28
cURL error:Operation timed out with 82 out of -1 bytes received
When I turned off the error logging and return transfer it gives:
PUT / HTTP/1.1,I Host: dac.nic.uk:2043,I Pragma: no-cache,I Accept: */*,I ,I
which is the same error when using curl from command line. The connection
appears to be taking the headers as requests, which gives the ,I return
errors.
I've mailed the technical people for the system to see if they have any
recommendations. Any other suggestions would be appreciated.
Thanks
Stephen
----- Original Message -----
From: "Daniel Stenberg" <daniel_at_haxx.se>
To: "curl with PHP" <curl-and-php_at_cool.haxx.se>
Sent: Monday, November 28, 2005 7:14 AM
Subject: Re: fsockopen replacment
> On Sun, 27 Nov 2005, StephenB wrote:
>
>> 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.
>
> always always always include libcurl version number and info about that
> platform it runs on.
>
>> $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);
>> }
>
> I don't know much PHP, but this is quite far from a PUT request...
>
>> $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);
>
> ... and this is a weird way to convert a GET request into a PUT.
>
> Did you try to append the port number in the URL string?
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-11-28