CURLOPT_IOCTLDATA(3)

✨ NAME ✨

CURLOPT_IOCTLDATA - pointer passed to I/O callback πŸ’…

🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLDATA, void *pointer);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so bestie, you pass in a pointer here, and libcurl literally does not touch it β€” it stays untouched by libcurl β€” and then it gets passed as the 3rd argument in the ioctl callback that you set with CURLOPT_IOCTLFUNCTION(3) ✨

πŸŽ€ DEFAULT πŸŽ€

NULL β€” that's the default, no pointer, periodt πŸ’–

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols β€” yes, all of them, no cap ✨

🧚 EXAMPLE 🧚

Here's the whole vibe, bestie:

#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. So yeah, this one is deprecated, bestie β€” noted and flagged πŸ™ˆ

⭐ 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 🫢


Signed, sealed, and delivered by libcurl πŸ’Œ dated 2026-10-12, all about CURLOPT_IOCTLDATA(3) β€” bye bestie! πŸ’–

πŸ“¦ where this page comes from