blob: 2a744398508092ff5006fe1245f85d35ecc9e4eb [file] [log] [blame]
Lucas Eckels9bd90e62012-08-06 15:07:02 -07001.\" **************************************************************************
2.\" * _ _ ____ _
3.\" * Project ___| | | | _ \| |
4.\" * / __| | | | |_) | |
5.\" * | (__| |_| | _ <| |___
6.\" * \___|\___/|_| \_\_____|
7.\" *
Alex Deymo8f1a2142016-06-28 14:49:26 -07008.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
Lucas Eckels9bd90e62012-08-06 15:07:02 -07009.\" *
10.\" * This software is licensed as described in the file COPYING, which
11.\" * you should have received as part of this distribution. The terms
Alex Deymo8f1a2142016-06-28 14:49:26 -070012.\" * are also available at https://curl.haxx.se/docs/copyright.html.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070013.\" *
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 "29 April 2008" "libcurl 7.18.2" "libcurl Manual"
24.SH NAME
25curl_easy_send - sends raw data over an "easy" connection
26.SH SYNOPSIS
27.B #include <curl/easy.h>
28.sp
29.BI "CURLcode curl_easy_send( CURL *" curl ", const void *" buffer ","
30.BI " size_t " buflen ", size_t *" n ");"
31.ad
32.SH DESCRIPTION
33This function sends arbitrary data over the established connection. You may
34use it together with \fIcurl_easy_recv(3)\fP to implement custom protocols
35using libcurl. This functionality can be particularly useful if you use
36proxies and/or SSL encryption: libcurl will take care of proxy negotiation and
37connection set-up.
38
39\fBbuffer\fP is a pointer to the data of length \fBbuflen\fP that you want sent.
40The variable \fBn\fP points to will receive the number of sent bytes.
41
Alex Deymo8f1a2142016-06-28 14:49:26 -070042To establish the connection, set \fICURLOPT_CONNECT_ONLY(3)\fP option before
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070043calling \fIcurl_easy_perform(3)\fP or \fIcurl_multi_perform()\fP. Note that
44\fIcurl_easy_send(3)\fP will not work on connections that were created without
45this option.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070046
47You must ensure that the socket is writable before calling
48\fIcurl_easy_send(3)\fP, otherwise the call will return \fBCURLE_AGAIN\fP -
49the socket is used in non-blocking mode internally. Use
Alex Deymo8f1a2142016-06-28 14:49:26 -070050\fIcurl_easy_getinfo(3)\fP with \fICURLINFO_ACTIVESOCKET(3)\fP to obtain the
Lucas Eckels9bd90e62012-08-06 15:07:02 -070051socket; use your operating system facilities like \fIselect(2)\fP to check if
52it can be written to.
53.SH AVAILABILITY
54Added in 7.18.2.
55.SH RETURN VALUE
56On success, returns \fBCURLE_OK\fP and stores the number of bytes actually
57sent into \fB*n\fP. Note that this may very well be less than the amount you
58wanted to send.
59
60On failure, returns the appropriate error code.
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070061
62If there's no socket available to use from the previous transfer, this function
63returns CURLE_UNSUPPORTED_PROTOCOL.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070064.SH EXAMPLE
65See \fBsendrecv.c\fP in \fBdocs/examples\fP directory for usage example.
66.SH "SEE ALSO"
67.BR curl_easy_setopt "(3), " curl_easy_perform "(3), " curl_easy_getinfo "(3), "
68.BR curl_easy_recv "(3) "