CURLOPT_FTPPORT.3 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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_FTPPORT 3 "January 02, 2023" "libcurl 7.88.1" "curl_easy_setopt options"
  26. .SH NAME
  27. CURLOPT_FTPPORT \- make FTP transfer active
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FTPPORT, char *spec);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a pointer to a null-terminated string as parameter. It specifies that the
  35. FTP transfer will be made actively and the given string will be used to get
  36. the IP address to use for the FTP PORT instruction.
  37. The PORT instruction tells the remote server to connect to our specified IP
  38. address. The string may be a plain IP address, a host name, a network
  39. interface name (under Unix) or just a '-' symbol to let the library use your
  40. system's default IP address. Default FTP operations are passive, and thus
  41. will not use PORT.
  42. The address can be followed by a ':' to specify a port, optionally followed by
  43. a '-' to specify a port range. If the port specified is 0, the operating
  44. system will pick a free port. If a range is provided and all ports in the
  45. range are not available, libcurl will report CURLE_FTP_PORT_FAILED for the
  46. handle. Invalid port/range settings are ignored. IPv6 addresses followed by a
  47. port or port range have to be in brackets. IPv6 addresses without port/range
  48. specifier can be in brackets.
  49. Examples with specified ports:
  50. .nf
  51. eth0:0
  52. 192.168.1.2:32000-33000
  53. curl.se:32123
  54. [::1]:1234-4567
  55. .fi
  56. We strongly advise against specifying the address with a name, as it causes
  57. libcurl to do a blocking name resolve call to retrieve the IP address. That
  58. name resolve operation will \fBnot\fP use DNS-over-HTTPS even if
  59. \fICURLOPT_DOH_URL(3)\fP is set.
  60. You disable PORT again and go back to using the passive version by setting
  61. this option to NULL.
  62. The application does not have to keep the string around after setting this
  63. option.
  64. .SH DEFAULT
  65. NULL
  66. .SH PROTOCOLS
  67. FTP
  68. .SH EXAMPLE
  69. .nf
  70. CURL *curl = curl_easy_init();
  71. if(curl) {
  72. curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/old-server/file.txt");
  73. curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
  74. ret = curl_easy_perform(curl);
  75. curl_easy_cleanup(curl);
  76. }
  77. .fi
  78. .SH AVAILABILITY
  79. Port range support was added in 7.19.5
  80. .SH RETURN VALUE
  81. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  82. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  83. .SH "SEE ALSO"
  84. .BR CURLOPT_FTP_USE_EPRT "(3), " CURLOPT_FTP_USE_EPSV "(3), "