libcurl.NET cannot resolve internal host when running in Visual Studio 2012 debugger

71 Views Asked by At

In the following C# program, CURL cannot resolve a local server inside the company. It works:

  1. for external URLs (e.g. http://www.google.com)
  2. when using WebRequest instead of CURL (first part in the code)

This is the program:

using SeasideResearch.LibCurlNet;
using System.Net;
using System.IO;

// ... class and method declaration

// first part - runs just fine, always
WebRequest r = WebRequest.Create("http://mycompanyserver");
using (Stream s = r.GetResponse().GetResponseStream())
{
    StreamReader sr = new StreamReader(s, Encoding.UTF8);
    string str;
    while ((str = sr.ReadLine()) != null)
    {
        Console.Out.WriteLine(str);
    }
}

// second part - returns CURLE_COULDNT_RESOLVE_HOST for simple URLs like http://hostname, but works for http://hostname.mycompany.com
Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
Easy easy = new Easy();
easy.SetOpt(CURLoption.CURLOPT_URL, "http://mycompanyserver");
CURLcode result = easy.Perform();
easy.Cleanup();
Curl.GlobalCleanup();

I've been on this now for two days, testing, googling, failing. It's so weird that it only fails for company-internal URLs. When I use curl from the command-line, it perfectly works ("curl -v http://mycompanyserver")

0

There are 0 best solutions below