1
.\" You can view this file with:
3
.\" $Id: libcurl.3,v 1.1 2002/03/04 10:09:49 bagder Exp $
5
.TH libcurl 5 "14 August 2001" "libcurl 7.8.1" "libcurl overview"
7
libcurl \- client-side URL transfers
9
This is an overview on how to use libcurl in your C programs. There are
10
specific man pages for each function mentioned in here. There's also the
11
libcurl-the-guide document for a complete tutorial to programming with
14
libcurl can also be used directly from within your Java, PHP, Perl, Ruby or
15
Tcl programs as well, look elsewhere for documentation on this!
17
All applications that use libcurl should call \fIcurl_global_init()\fP exactly
18
once before any libcurl function can be used. After all usage of libcurl is
19
complete, it \fBmust\fP call \fIcurl_global_cleanup()\fP. In between those two
20
calls, you can use libcurl as described below.
22
When using libcurl you init your session and get a handle, which you use as
23
input to the following interface functions you use. Use \fIcurl_easy_init()\fP
26
You continue by setting all the options you want in the upcoming transfer,
27
most important among them is the URL itself (you can't transfer anything
28
without a specified URL as you may have figured out yourself). You might want
29
to set some callbacks as well that will be called from the library when data
30
is available etc. \fIcurl_easy_setopt()\fP is there for this.
32
When all is setup, you tell libcurl to perform the transfer using
33
\fIcurl_easy_perform()\fP. It will then do the entire operation and won't
34
return until it is done (successfully or not).
36
After the transfer has been made, you can set new options and make another
37
transfer, or if you're done, cleanup the session by calling
38
\fIcurl_easy_cleanup()\fP. If you want persistant connections, you don't
39
cleanup immediately, but instead run ahead and perform other transfers using
40
the same handle. See the chapter below for Persistant Connections.
42
There is also a series of other helpful functions to use. They are:
47
displays the libcurl version
50
converts a date string to time_t
53
portable environment variable reader
55
.B curl_easy_getinfo()
56
get information about a performed transfer
59
helps building a HTTP form POST
62
free a list built with curl_formparse()/curl_formadd()
64
.B curl_slist_append()
67
.B curl_slist_free_all()
68
frees a whole curl_slist
71
portable printf() functions
74
portable case insensitive string comparisons
77
.SH "LINKING WITH LIBCURL"
78
Starting with 7.7.2 (on unix-like machines), there's a tool named curl-config
79
that gets installed with the rest of the curl stuff when 'make install' is
82
curl-config is added to make it easier for applications to link with libcurl
83
and developers to learn about libcurl and how to use it.
85
Run 'curl-config --libs' to get the (additional) linker options you need to
86
link with the particular version of libcurl you've installed.
88
For details, see the curl-config.1 man page.
89
.SH "LIBCURL SYMBOL NAMES"
90
All public functions in the libcurl interface are prefixed with 'curl_' (with
91
a lowercase c). You can find other functions in the library source code, but
92
other prefixes indicate the functions are private and may change without
93
further notice in the next release.
95
Only use documented functions and functionality!
99
the same, on any of the platforms it compiles and builds on.
101
There's only one caution, and that is the win32 platform that may(*) require
102
you to init the winsock stuff before you use the libcurl functions. Details on
103
this are noted on the curl_easy_init() man page.
105
(*) = it appears as if users of the cygwin environment get this done
106
automatically, also libcurl 7.8.1 and later can handle this for you.
108
Never ever call curl-functions simultaneously using the same handle from
109
several threads. libcurl is thread-safe and can be used in any number of
110
threads, but you must use separate curl handles if you want to use libcurl in
111
more than one thread simultaneously.
112
.SH "PERSISTANT CONNECTIONS"
113
With libcurl 7.7, persistant connections were added. Persistant connections
114
means that libcurl can re-use the same connection for several transfers, if
115
the conditions are right.
117
libcurl will *always* attempt to use persistant connections. Whenever you use
118
curl_easy_perform(), libcurl will attempt to use an existing connection to do
119
the transfer, and if none exists it'll open a new one that will be subject
120
for re-use on a possible following call to curl_easy_perform().
122
To allow libcurl to take full advantage of persistant connections, you should
123
do as many of your file transfers as possible using the same curl
124
handle. When you call curl_easy_cleanup(), all the possibly open connections
125
held by libcurl will be closed and forgotten.
127
Note that the options set with curl_easy_setopt() will be used in on every
128
repeat curl_easy_perform() call
129
.SH "COMPATIBILITY WITH OLDER LIBCURLS"
130
Repeated curl_easy_perform() calls on the same handle were not supported in
131
pre-7.7 versions, and caused confusion and undefined behaviour.