---
name: "io_getcookie"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/io_getcookie"
---

# io\_getcookie(3)

retrieve cookie

## NAME

io\_getcookie - retrieve cookie

## SYNTAX

**#include \<libowfat/io.h\>**

void\* **io\_getcookie**(int64 fd);

## DESCRIPTION

io\_getcookie retrieves a cookie (pointer to some anonymous data structure you associated with this descriptor).

Use [io\_setcookie(3)](/io_setcookie/3.md) to associate a cookie with a descriptor.

If you did not associate a cookie with this descriptor, io\_getcookie returns NULL.

The idea is that you put the state associated with a TCP connection you serve in a common struct.  Then you do not need to have your own data structure to retrieve the state for a connection, you can just use the data structure io\_wait already maintains.  The lookup works in constant time and should not cause any cache misses.

## SEE ALSO

[io\_wait(3)](/io_wait/3.md), [io\_setcookie(3)](/io_setcookie/3.md)
