cURL / Mailing Lists / curl-library / Single Mail

curl-library

SRV and libcurl

From: David Shaw <dshaw_at_jabberwocky.com>
Date: Wed, 22 Feb 2006 14:26:08 -0500

I've looked in the list archives, and it seems that the idea of using
DNS SRV with libcurl comes up every now and then.

I think this is an excellent idea, and while I don't have code
(sorry), perhaps a good start would be to discuss an API. Here's some
ideas:

*) Create two new options, CURLOPT_SRV_SERVICE, which takes a
   string for the SRV tag, and CURLOPT_SRV_TRANSPORT which takes a
   string for the SRV transport. CURLOPT_SRV_TRANSPORT defaults to
   "tcp". CURLOPT_SRV_SERVICE defaults to nothing. If either are not
   set, or set to a null string or a zero-length string, SRV is not
   done.

*) The server-picking algorithm is specified in RFC-2782 and is pretty
   straightforward. A possible optimization could be if libcurl
   happened to have a cached connection to a server at the same
   priority (but not necessarily the same weight), libcurl might want
   to give more weight to the cached connection to lessen the chance
   of being required to open a new connection.

* If the URL has a :port specified in it, that port is used. If there
  is no port specified, the port from the SRV list is used.

*) By default nothing different happens for backwards compatibility.

For example:

  curl_easy_setopt(CURLOPT_SRV_SERVICE,"whatever");
  curl_easy_setopt(CURLOPT_SRV_TRANSPORT,"tcp");
  curl_easy_setopt(CURLOPT_URL,"http://foo.bar.baz/thefile.html");

would result in a SRV lookup of:

  _whatever._tcp.foo.bar.baz

the SRV weighting algorithm would run as normal, and the server
decided on would be contacted via HTTP for /thefile.html.

David
Received on 2006-02-22