Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / curl_easy_send.3
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 .\"
23 .TH curl_easy_send 3 "December 18, 2016" "libcurl 7.59.0" "libcurl Manual"
24
25 .SH NAME
26 curl_easy_send - sends raw data over an "easy" connection
27 .SH SYNOPSIS
28 .B #include <curl/easy.h>
29 .sp
30 .BI "CURLcode curl_easy_send( CURL *" curl ", const void *" buffer ","
31 .BI " size_t " buflen ", size_t *" n ");"
32 .ad
33 .SH DESCRIPTION
34 This function sends arbitrary data over the established connection. You may
35 use it together with \fIcurl_easy_recv(3)\fP to implement custom protocols
36 using libcurl. This functionality can be particularly useful if you use
37 proxies and/or SSL encryption: libcurl will take care of proxy negotiation and
38 connection set-up.
39
40 \fBbuffer\fP is a pointer to the data of length \fBbuflen\fP that you want sent.
41 The variable \fBn\fP points to will receive the number of sent bytes.
42
43 To establish the connection, set \fICURLOPT_CONNECT_ONLY(3)\fP option before
44 calling \fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform(3)\fP. Note that
45 \fIcurl_easy_send(3)\fP will not work on connections that were created without
46 this option.
47
48 The call will return \fBCURLE_AGAIN\fP if it's not possible to send data right
49 now - the socket is used in non-blocking mode internally. When
50 \fBCURLE_AGAIN\fP is returned, use your operating system facilities like
51 \fIselect(2)\fP to wait until the socket is writable. The socket may be
52 obtained using \fIcurl_easy_getinfo(3)\fP with \fICURLINFO_ACTIVESOCKET(3)\fP.
53
54 Furthermore if you wait on the socket and it tells you it's writable,
55 \fIcurl_easy_send(3)\fP may return \fBCURLE_AGAIN\fP if the only data that was
56 sent was for internal SSL processing, and no other data could be sent.
57
58 .SH AVAILABILITY
59 Added in 7.18.2.
60 .SH RETURN VALUE
61 On success, returns \fBCURLE_OK\fP and stores the number of bytes actually
62 sent into \fB*n\fP. Note that this may very well be less than the amount you
63 wanted to send.
64
65 On failure, returns the appropriate error code.
66
67 This function may return \fBCURLE_AGAIN\fP. In this case, use your operating
68 system facilities to wait until the socket is writable, and retry.
69
70 If there's no socket available to use from the previous transfer, this function
71 returns \fBCURLE_UNSUPPORTED_PROTOCOL\fP.
72 .SH EXAMPLE
73 See \fBsendrecv.c\fP in \fBdocs/examples\fP directory for usage example.
74 .SH "SEE ALSO"
75 .BR curl_easy_setopt "(3), " curl_easy_perform "(3), " curl_easy_getinfo "(3), "
76 .BR curl_easy_recv "(3) "