---
name: "gensio_set_callback"
section: "3"
platform: "linux"
package: "gensio"
version: "3.0.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/gensio_set_callback"
---

# gensio\_set\_callback(3)

Set the event callback and user data for a gensio

## NAME

gensio\_set\_callback, gensio\_get\_user\_data, gensio\_set\_user\_data - Set the event callback and user data for a gensio

## SYNOPSIS

**#include \<gensio/gensio.h\>**

- **void gensio\_set\_callback(struct gensio \*io,**

  **gensio\_event cb, void \*user\_data)**

- **void gensio\_set\_user\_data(struct gensio \*io, void \*user\_data);**

  - **void \*gensio\_get\_user\_data(struct gensio \*io)**

  ## DESCRIPTION

**gensio\_set\_callback** sets the event handler and data for the gensio.  This must be done in the **GENSIO\_ACC\_EVENT\_NEW\_CONNECTION** event from a **gensio\_accepter** before any other operation is done on the gensio. The only exception is that **gensio\_close** may be called with callbacks not set.  This function may be called again if the gensio cannot generate any callbacks, generally after it has been closed.  Otherwise race conditions may occur.

**gensio\_set\_user\_data** Just sets the user\_data field in the gensio.  If this is called when the gensio is running, race conditions may occur.

**gensio\_get\_user\_data** Return the user data passed in with the gensio was created or set by one of the above two functions.

## SEE ALSO

[gensio(5)](/gensio/5.md), [gensio\_event(3)](/gensio_event/3.md), [gensio\_accepter\_event(3)](/gensio_accepter_event/3.md)
