curl_easy_perform.3 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2016, 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.haxx.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. .\" **************************************************************************
  22. .TH curl_easy_perform 3 "5 Mar 2001" "libcurl 7.7" "libcurl Manual"
  23. .SH NAME
  24. curl_easy_perform - perform a blocking file transfer
  25. .SH SYNOPSIS
  26. .B #include <curl/curl.h>
  27. .sp
  28. .BI "CURLcode curl_easy_perform(CURL *" easy_handle ");"
  29. .ad
  30. .SH DESCRIPTION
  31. Invoke this function after \fIcurl_easy_init(3)\fP and all the
  32. \fIcurl_easy_setopt(3)\fP calls are made, and will perform the transfer as
  33. described in the options. It must be called with the same \fBeasy_handle\fP as
  34. input as the \fIcurl_easy_init(3)\fP call returned.
  35. \fIcurl_easy_perform(3)\fP performs the entire request in a blocking manner
  36. and returns when done, or if it failed. For non-blocking behavior, see
  37. \fIcurl_multi_perform(3)\fP.
  38. You can do any amount of calls to \fIcurl_easy_perform(3)\fP while using the
  39. same \fBeasy_handle\fP. If you intend to transfer more than one file, you are
  40. even encouraged to do so. libcurl will then attempt to re-use the same
  41. connection for the following transfers, thus making the operations faster,
  42. less CPU intense and using less network resources. Just note that you will
  43. have to use \fIcurl_easy_setopt(3)\fP between the invokes to set options for
  44. the following curl_easy_perform.
  45. You must never call this function simultaneously from two places using the
  46. same \fBeasy_handle\fP. Let the function return first before invoking it
  47. another time. If you want parallel transfers, you must use several curl
  48. easy_handles.
  49. While the \fBeasy_handle\fP is added to a multi handle, it cannot be used by
  50. \fIcurl_easy_perform(3)\fP.
  51. .SH RETURN VALUE
  52. CURLE_OK (0) means everything was ok, non-zero means an error occurred as
  53. .I <curl/curl.h>
  54. defines - see \fIlibcurl-errors(3)\fP. If the \fICURLOPT_ERRORBUFFER(3)\fP was
  55. set with \fIcurl_easy_setopt(3)\fP there will be a readable error message in
  56. the error buffer when non-zero is returned.
  57. .SH EXAMPLE
  58. .nf
  59. CURL *curl = curl_easy_init();
  60. if(curl) {
  61. CURLcode res;
  62. curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  63. res = curl_easy_perform(curl);
  64. curl_easy_cleanup(curl);
  65. }
  66. .fi
  67. .SH "SEE ALSO"
  68. .BR curl_easy_init "(3), " curl_easy_setopt "(3), "
  69. .BR curl_multi_add_handle "(3), " curl_multi_perform "(3), "
  70. .BR libcurl-errors "(3), "