1io_setcookie(3) Library Functions Manual io_setcookie(3)
2
3
4
6 io_setcookie - associate cookie with descriptor
7
9 #include <io.h>
10
11 void io_setcookie(int64 fd,void* cookie);
12
14 io_setcookie associates a cookie (pointer to some anonymous data strucā
15 ture) with this descriptor. Only one cookie can be associated with a
16 descriptor.
17
18 Use io_getcookie(3) to retrieve the cookie for a descriptor (usually
19 after io_canread or io_canwrite brought it to your attention).
20
21 Please note that io_close does not deallocate your cookie. You need to
22 do that yourself.
23
24 The idea is that you put the state associated with a TCP connection you
25 serve in a common struct. Then you do not need to have your own data
26 structure to retrieve the state for a connection, you can just use the
27 data structure io_wait already maintains. The lookup works in constant
28 time and should not cause any cache misses.
29
31 io_wait(3), io_getcookie(3)
32
33
34
35 io_setcookie(3)