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

curl-and-php

Re: fsockopen replacment

From: StephenB <sb1304_at_hotmail.com>
Date: Mon, 28 Nov 2005 11:22:01 -0000

Mark/Daniel. Treat a novice kindly. Curl looks fun, but usage documentation
is sparce. The quick responses are appreciated though.

The server response through telnet is:
[~]# telnet dac.nic.uk 2043
Trying 195.66.240.114...
Connected to dac.nic.uk.
Escape character is '^]'.
domain.co.uk
domain.co.uk,Y,N,N,2003-07-29,2007-07-29,2
garbage
garbage,I
^]
telnet> quit
Connection closed.

where domain is the command line put and the last line the immediate return.
An invalid request gives-> request,I. The file contains a single domain
name.

<?php
$curlFile = fopen (file, "r");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://dac.nic.uk:2043');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_INFILE, $curlFile);
curl_setopt($ch, CURLOPT_INFILESIZE, -1);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$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->>" . $data . "<--<br/>";
?>

gives a timeout response with: Array ( [url] => http://dac.nic.uk:2043
[http_code] => 0 [header_size] => 0 [request_size] => 94 [filetime] => -1
[ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 5.257343
[namelookup_time] => 0.00534 [connect_time] => 0.079506 [pretransfer_time]
=> 0.079655 [size_upload] => 13 [size_download] => 106 [speed_download] =>
20 [speed_upload] => 2 [download_content_length] => 0
[upload_content_length] => -1 [starttransfer_time] => 2.077903
[redirect_time] => 0 ) cURL error number:28 cURL error:Operation timed out
with 106 out of -1 bytes received
data->><--

removing the error reporting gives:
PUT / HTTP/1.1,I Host: dac.nic.uk:2043,I Pragma: no-cache,I Accept: */*,I
Expect: 100-continue,I ,I
data->><--

It appears that the connection is taking each line of the headers as a
request. I'm not sure if there's a way around this.

Any suggestions on using telnet through curl would be appreciated.

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 10:11 AM
Subject: Re: fsockopen replacment

> On Mon, 28 Nov 2005, StephenB wrote:
>
>> curl info: curl 7.12.0
>
> CURLOPT_PORT didn't work properly back then.
>
>> I've tried it with the port on the url and it seems to connect, but gives
>> the following error:
>
>> cURL error:Operation timed out with 82 out of -1 bytes received
>
> So it times out.
>
>> 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
>
> Is that what the server responds?!
>
>> which is the same error when using curl from command line.
>
> And how do you do that request from the command line?
>
>> The connection appears to be taking the headers as requests, which gives
>> the ,I return errors.
>
> The "connection" ? You mean the server?
>
>> I've mailed the technical people for the system to see if they have any
>> recommendations. Any other suggestions would be appreciated.
>
> It might help if you told us what your attempts should be doing instead of
> just showing us what you do.
>
> Why are you trying to send an empty PUT ? It doesn't make sense.
>
> --
> 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