CURLOPT_IOCTLFUNCTION(3)
π CURLOPT_IOCTLFUNCTION(3) β Library Functions Manual π
okay so bestie, this page is from the Library Functions Manual, and it's all about a callback for I/O operations. Also? It's deprecated. We'll get there, don't panic. π¦
β¨ NAME β¨
CURLOPT_IOCTLFUNCTION β callback for I/O operations
π SYNOPSIS π
head empty, just these exact declarations:
#include <curl/curl.h>
typedef enum {
CURLIOE_OK, /* I/O operation successful */
CURLIOE_UNKNOWNCMD, /* command was unknown to callback */
CURLIOE_FAILRESTART, /* failed to restart the read */
CURLIOE_LAST /* never use */
} curlioerr;
typedef enum {
CURLIOCMD_NOP, /* no operation */
CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
CURLIOCMD_LAST /* never use */
} curliocmd;
curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp);
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback);
πΈ DESCRIPTION πΈ
Pass a pointer to your callback function, and it should match the prototype shown above. π
This callback function gets called by libcurl when something special I/O-related needs to be done that the library cannot do by itself. For now, rewinding the read data stream is the only action it can request. The rewinding of the read data stream may be necessary when doing an HTTP PUT or POST with a multi-pass authentication method.
Your callback must return CURLIOE_UNKNOWNCMD if the input cmd is not CURLIOCMD_RESTARTREAD.
The clientp argument to the callback is set with the CURLOPT_IOCTLDATA(3) option.
β οΈ This option is deprecated. Do not use it. UseCURLOPT_SEEKFUNCTION(3)instead to provide seeking. IfCURLOPT_SEEKFUNCTION(3)is set, this parameter is ignored when seeking.
π DEFAULT π
NULL
π PROTOCOLS π
This functionality affects all supported protocols. periodt.
π§ EXAMPLE π§
Here's the example, exactly as it ships β no cap:
#include <unistd.h> /* for lseek */
struct data {
int fd; /* our file descriptor */
};
static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
{
struct data *io = (struct data *)clientp;
if(cmd == CURLIOCMD_RESTARTREAD) {
lseek(io->fd, 0, SEEK_SET);
return CURLIOE_OK;
}
return CURLIOE_UNKNOWNCMD;
}
int main(void)
{
struct data ioctl_data;
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
}
}
π DEPRECATED π
Deprecated since 7.18.0.
Yeah. This is a do-not-use situation, bestie. π
π AVAILABILITY π
Added in curl 7.12.3.
π«Ά RETURN VALUE π«Ά
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).
π₯ SEE ALSO π₯
later, bestie π«Ά β source/version: libcurl, date: 2026-10-12. mwah π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms