CURLOPT_INTERFACE.3 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_INTERFACE 3 "May 17, 2022" "libcurl 7.85.0" "curl_easy_setopt options"
  26. .SH NAME
  27. CURLOPT_INTERFACE \- source interface for outgoing traffic
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INTERFACE, char *interface);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a char * as parameter. This sets the \fIinterface\fP name to use as
  35. outgoing network interface. The name can be an interface name, an IP address,
  36. or a host name.
  37. If the parameter starts with "if!" then it is treated as only as interface
  38. name and no attempt will ever be named to do treat it as an IP address or to
  39. do name resolution on it. If the parameter starts with \&"host!" it is
  40. treated as either an IP address or a hostname. Hostnames are resolved
  41. synchronously. Using the if! format is highly recommended when using the
  42. multi interfaces to avoid allowing the code to block. If "if!" is specified
  43. but the parameter does not match an existing interface, CURLE_INTERFACE_FAILED
  44. is returned from the libcurl function used to perform the transfer.
  45. libcurl does not support using network interface names for this option on
  46. Windows.
  47. The application does not have to keep the string around after setting this
  48. option.
  49. .SH DEFAULT
  50. NULL, use whatever the TCP stack finds suitable
  51. .SH PROTOCOLS
  52. All
  53. .SH EXAMPLE
  54. .nf
  55. CURL *curl = curl_easy_init();
  56. if(curl) {
  57. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  58. curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
  59. ret = curl_easy_perform(curl);
  60. curl_easy_cleanup(curl);
  61. }
  62. .fi
  63. .SH AVAILABILITY
  64. The "if!" and "host!" syntax was added in 7.24.0.
  65. .SH RETURN VALUE
  66. Returns CURLE_OK on success or
  67. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  68. .SH "SEE ALSO"
  69. .BR CURLOPT_SOCKOPTFUNCTION "(3), " CURLOPT_TCP_NODELAY "(3), "