诸暨麻将添加redis
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

223 líneas
11 KiB

  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2011, 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 http://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 libcurl 3 "19 March 2002" "libcurl 7.9.6" "libcurl overview"
  23. .SH NAME
  24. libcurl \- client-side URL transfers
  25. .SH DESCRIPTION
  26. This is a short overview on how to use libcurl in your C programs. There are
  27. specific man pages for each function mentioned in here. There are also the
  28. \fIlibcurl-easy(3)\fP man page, the \fIlibcurl-multi(3)\fP man page, the
  29. \fIlibcurl-share(3)\fP man page and the \fIlibcurl-tutorial(3)\fP man page for
  30. in-depth understanding on how to program with libcurl.
  31. There are more than thirty custom bindings available that bring libcurl access
  32. to your favourite language. Look elsewhere for documentation on those.
  33. libcurl has a global constant environment that you must set up and
  34. maintain while using libcurl. This essentially means you call
  35. \fIcurl_global_init(3)\fP at the start of your program and
  36. \fIcurl_global_cleanup(3)\fP at the end. See GLOBAL CONSTANTS below
  37. for details.
  38. To transfer files, you always set up an "easy handle" using
  39. \fIcurl_easy_init(3)\fP, but when you want the file(s) transferred you have
  40. the option of using the "easy" interface, or the "multi" interface.
  41. The easy interface is a synchronous interface with which you call
  42. \fIcurl_easy_perform(3)\fP and let it perform the transfer. When it is
  43. completed, the function returns and you can continue. More details are found in
  44. the \fIlibcurl-easy(3)\fP man page.
  45. The multi interface on the other hand is an asynchronous interface, that you
  46. call and that performs only a little piece of the transfer on each invoke. It
  47. is perfect if you want to do things while the transfer is in progress, or
  48. similar. The multi interface allows you to select() on libcurl action, and
  49. even to easily download multiple files simultaneously using a single thread. See further details in the \fIlibcurl-multi(3)\fP man page.
  50. You can have multiple easy handles share certain data, even if they are used
  51. in different threads. This magic is setup using the share interface, as
  52. described in the \fIlibcurl-share(3)\fP man page.
  53. There is also a series of other helpful functions to use, including these:
  54. .RS
  55. .IP curl_version_info()
  56. gets detailed libcurl (and other used libraries) version info
  57. .IP curl_getdate()
  58. converts a date string to time_t
  59. .IP curl_easy_getinfo()
  60. get information about a performed transfer
  61. .IP curl_formadd()
  62. helps building an HTTP form POST
  63. .IP curl_formfree()
  64. free a list built with \fIcurl_formadd(3)\fP
  65. .IP curl_slist_append()
  66. builds a linked list
  67. .IP curl_slist_free_all()
  68. frees a whole curl_slist
  69. .RE
  70. .SH "LINKING WITH LIBCURL"
  71. On unix-like machines, there's a tool named curl-config that gets installed
  72. with the rest of the curl stuff when 'make install' is performed.
  73. curl-config is added to make it easier for applications to link with libcurl
  74. and developers to learn about libcurl and how to use it.
  75. Run 'curl-config --libs' to get the (additional) linker options you need to
  76. link with the particular version of libcurl you've installed. See the
  77. \fIcurl-config(1)\fP man page for further details.
  78. Unix-like operating system that ship libcurl as part of their distributions
  79. often don't provide the curl-config tool, but simply install the library and
  80. headers in the common path for this purpose.
  81. .SH "LIBCURL SYMBOL NAMES"
  82. All public functions in the libcurl interface are prefixed with 'curl_' (with
  83. a lowercase c). You can find other functions in the library source code, but
  84. other prefixes indicate that the functions are private and may change without
  85. further notice in the next release.
  86. Only use documented functions and functionality!
  87. .SH "PORTABILITY"
  88. libcurl works
  89. .B exactly
  90. the same, on any of the platforms it compiles and builds on.
  91. .SH "THREADS"
  92. Never ever call curl-functions simultaneously using the same handle from
  93. several threads. libcurl is thread-safe and can be used in any number of
  94. threads, but you must use separate curl handles if you want to use libcurl in
  95. more than one thread simultaneously.
  96. The global environment functions are not thread-safe. See GLOBAL CONSTANTS
  97. below for details.
  98. .SH "PERSISTENT CONNECTIONS"
  99. Persistent connections means that libcurl can re-use the same connection for
  100. several transfers, if the conditions are right.
  101. libcurl will \fBalways\fP attempt to use persistent connections. Whenever you
  102. use \fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP, libcurl will
  103. attempt to use an existing connection to do the transfer, and if none exists
  104. it'll open a new one that will be subject for re-use on a possible following
  105. call to \fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP.
  106. To allow libcurl to take full advantage of persistent connections, you should
  107. do as many of your file transfers as possible using the same curl handle. When
  108. you call \fIcurl_easy_cleanup(3)\fP, all the possibly open connections held by
  109. libcurl will be closed and forgotten.
  110. Note that the options set with \fIcurl_easy_setopt(3)\fP will be used on
  111. every repeated \fIcurl_easy_perform(3)\fP call.
  112. .SH "GLOBAL CONSTANTS"
  113. There are a variety of constants that libcurl uses, mainly through its
  114. internal use of other libraries, which are too complicated for the
  115. library loader to set up. Therefore, a program must call a library
  116. function after the program is loaded and running to finish setting up
  117. the library code. For example, when libcurl is built for SSL
  118. capability via the GNU TLS library, there is an elaborate tree inside
  119. that library that describes the SSL protocol.
  120. \fIcurl_global_init()\fP is the function that you must call. This may
  121. allocate resources (e.g. the memory for the GNU TLS tree mentioned
  122. above), so the companion function \fIcurl_global_cleanup()\fP releases
  123. them.
  124. The basic rule for constructing a program that uses libcurl is this:
  125. Call \fIcurl_global_init()\fP, with a \fICURL_GLOBAL_ALL\fP argument,
  126. immediately after the program starts, while it is still only one
  127. thread and before it uses libcurl at all. Call
  128. \fIcurl_global_cleanup()\fP immediately before the program exits, when
  129. the program is again only one thread and after its last use of
  130. libcurl.
  131. You can call both of these multiple times, as long as all calls meet
  132. these requirements and the number of calls to each is the same.
  133. It isn't actually required that the functions be called at the beginning
  134. and end of the program -- that's just usually the easiest way to do it.
  135. It \fIis\fP required that the functions be called when no other thread
  136. in the program is running.
  137. These global constant functions are \fInot thread safe\fP, so you must
  138. not call them when any other thread in the program is running. It
  139. isn't good enough that no other thread is using libcurl at the time,
  140. because these functions internally call similar functions of other
  141. libraries, and those functions are similarly thread-unsafe. You can't
  142. generally know what these libraries are, or whether other threads are
  143. using them.
  144. The global constant situation merits special consideration when the
  145. code you are writing to use libcurl is not the main program, but rather
  146. a modular piece of a program, e.g. another library. As a module,
  147. your code doesn't know about other parts of the program -- it doesn't
  148. know whether they use libcurl or not. And its code doesn't necessarily
  149. run at the start and end of the whole program.
  150. A module like this must have global constant functions of its own,
  151. just like \fIcurl_global_init()\fP and \fIcurl_global_cleanup()\fP.
  152. The module thus has control at the beginning and end of the program
  153. and has a place to call the libcurl functions. Note that if multiple
  154. modules in the program use libcurl, they all will separately call the
  155. libcurl functions, and that's OK because only the first
  156. \fIcurl_global_init()\fP and the last \fIcurl_global_cleanup()\fP in a
  157. program change anything. (libcurl uses a reference count in static
  158. memory).
  159. In a C++ module, it is common to deal with the global constant
  160. situation by defining a special class that represents the global
  161. constant environment of the module. A program always has exactly one
  162. object of the class, in static storage. That way, the program
  163. automatically calls the constructor of the object as the program
  164. starts up and the destructor as it terminates. As the author of this
  165. libcurl-using module, you can make the constructor call
  166. \fIcurl_global_init()\fP and the destructor call
  167. \fIcurl_global_cleanup()\fP and satisfy libcurl's requirements without
  168. your user having to think about it.
  169. \fIcurl_global_init()\fP has an argument that tells what particular
  170. parts of the global constant environment to set up. In order to
  171. successfully use any value except \fICURL_GLOBAL_ALL\fP (which says to
  172. set up the whole thing), you must have specific knowledge of internal
  173. workings of libcurl and all other parts of the program of which it is
  174. part.
  175. A special part of the global constant environment is the identity of
  176. the memory allocator. \fIcurl_global_init()\fP selects the system
  177. default memory allocator, but you can use \fIcurl_global_init_mem()\fP
  178. to supply one of your own. However, there is no way to use
  179. \fIcurl_global_init_mem()\fP in a modular program -- all modules in
  180. the program that might use libcurl would have to agree on one
  181. allocator.
  182. There is a failsafe in libcurl that makes it usable in simple
  183. situations without you having to worry about the global constant
  184. environment at all: \fIcurl_easy_init()\fP sets up the environment
  185. itself if it hasn't been done yet. The resources it acquires to do so
  186. get released by the operating system automatically when the program
  187. exits.
  188. This failsafe feature exists mainly for backward compatibility because
  189. there was a time when the global functions didn't exist. Because it
  190. is sufficient only in the simplest of programs, it is not recommended
  191. for any program to rely on it.