1CURLOPT_UNIX_SOCKET_PATH(3)curl_easy_setopt optionsCURLOPT_UNIX_SOCKET_PATH(3)
2
3
4

NAME

6       CURLOPT_UNIX_SOCKET_PATH - Unix domain socket
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UNIX_SOCKET_PATH, char *path);
12

DESCRIPTION

14       Enables  the use of Unix domain sockets as connection endpoint and sets
15       the path to path. If path is NULL, then Unix domain  sockets  are  dis‐
16       abled.  An  empty string will result in an error at some point, it will
17       not disable use of Unix domain sockets.
18
19       When enabled, curl will connect to the Unix domain  socket  instead  of
20       establishing  a  TCP  connection  to a host. Since no TCP connection is
21       created, curl does not need to resolve the DNS hostname in the URL.
22
23       The maximum path length on Cygwin, Linux and Solaris is 107.  On  other
24       platforms it might be even less.
25
26       Proxy and TCP options such as CURLOPT_TCP_NODELAY(3) are not supported.
27       Proxy options such as CURLOPT_PROXY(3) have no effect either  as  these
28       are  TCP-oriented,  and  asking  a proxy server to connect to a certain
29       Unix domain socket is not possible.
30
31       The application does not have to keep the string around  after  setting
32       this option.
33

DEFAULT

35       Default is NULL, meaning that no Unix domain sockets are used.
36

PROTOCOLS

38       All  protocols  except  for FILE and FTP are supported in theory. HTTP,
39       IMAP, POP3 and SMTP should in particular work (including their  SSL/TLS
40       variants).
41

EXAMPLE

43       Given   that   you   have   an   HTTP   server   running  listening  on
44       /tmp/httpd.sock, you can request an HTTP resource with:
45
46         curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, "/tmp/httpd.sock");
47         curl_easy_setopt(curl_handle, CURLOPT_URL, "http://localhost/");
48
49       If you are on Linux and somehow have a need for paths larger  than  107
50       bytes, you could use the proc filesystem to bypass the limitation:
51
52         int dirfd = open(long_directory_path_to_socket, O_DIRECTORY | O_RDONLY);
53         char path[108];
54         snprintf(path, sizeof(path), "/proc/self/fd/%d/httpd.sock", dirfd);
55         curl_easy_setopt(curl_handle, CURLOPT_UNIX_SOCKET_PATH, path);
56         /* Be sure to keep dirfd valid until you discard the handle */
57

AVAILABILITY

59       Added in 7.40.0.
60

RETURN VALUE

62       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
63       if not.
64

SEE ALSO

66       CURLOPT_ABSTRACT_UNIX_SOCKET(3),         CURLOPT_OPENSOCKETFUNCTION(3),
67       unix(7),
68
69
70
71libcurl 7.82.0                 November 26, 2021   CURLOPT_UNIX_SOCKET_PATH(3)
Impressum