digitalmars.D.learn - Curl namelookup_time
- Andre Pany (20/20) Nov 23 2016 Hi,
- Adam D. Ruppe (15/17) Nov 23 2016 curl_easy_getinfo expects the C handle, CURL*, but you are
- Andre Pany (7/13) Nov 23 2016 Thank you Adam. I will create a bug report and also an
Hi, I try to get some cUrl measurements like name lookup time. pragma(lib, "curl"); import std.stdio, std.net.curl, etc.c.curl; void main() { Curl curl; curl.initialize(); curl.set(CurlOption.url, "https://www.google.com"); curl.perform(); double d; curl_easy_getinfo(&curl, CurlInfo.namelookup_time, &d); writeln(d); } While the cUrl console application return values like "0,015", this coding returns values like "9.71874e-311". Where is the bug? Kind regards André
Nov 23 2016
On Wednesday, 23 November 2016 at 08:24:46 UTC, Andre Pany wrote:Curl curl; curl_easy_getinfo(&curl, CurlInfo.namelookup_time, &d);curl_easy_getinfo expects the C handle, CURL*, but you are passing it the D struct, Curl. I don't understand why this even compiles, it should give an invalid argument type error.... let me guess, it has `alias void CURL`... hey look, there it is: http://dpldocs.info/experimental-docs/source/etc.c.curl.d.html#L110 thanks, zero typechecks. It really should be an opaque struct. Lemme guess too, it was a typedef in C. https://github.com/curl/curl/blob/master/include/curl/curl.h#L102 gee, typedef and alias aren't the same! This is a bug. A REALLY common bug. Anyway, as to your specific instance, the D Curl struct has no public function to return the underlying C handle. To use the C functions, you'll have to create them using C functions too.
Nov 23 2016
On Wednesday, 23 November 2016 at 13:59:29 UTC, Adam D. Ruppe wrote:On Wednesday, 23 November 2016 at 08:24:46 UTC, Andre Pany wrote:Thank you Adam. I will create a bug report and also an enhancement request. Getting the the time values is quite cumbersome:) Kind regards André[...]curl_easy_getinfo expects the C handle, CURL*, but you are passing it the D struct, Curl. [...]
Nov 23 2016