# Waiting in Eio for socket data without reading it

**URL:** <https://discuss.ocaml.org/t/waiting-in-eio-for-socket-data-without-reading-it/17615>\
**Category:** Ecosystem\
**Tags:** unix, socket, networking, concurrency, eio\
**Created:** [December 20, 2025, 2:19pm UTC](https://discuss.ocaml.org/t/waiting-in-eio-for-socket-data-without-reading-it/17615 "2025-12-20T14:19:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vog](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vog/32/6323_2.png) [@vog](https://discuss.ocaml.org/u/vog)\
**Post date:** [December 20, 2025, 2:19pm UTC](https://discuss.ocaml.org/t/waiting-in-eio-for-socket-data-without-reading-it/17615/1 "2025-12-20T14:19:30Z")

</div>

I’d like to wrap a C library for use within Eio code. That library opens a network connection on its own, but I’m able to fetch the file descriptor of the open socket. It even operates in non-blocking mode.

But how do I wait in Eio until new input is available?

Can I somehow e.g. wrap that file descriptor into an `Eio.Resource` or `Eio.Flow`, and read from it without actually reading any single byte (as that would disturb the C library)?

I’m aware that I could call Unix.socket or Unix.poll, and that I would have to wrap it within `Eio_unix.run_in_systhread`. However, is there a way without starting a separate thread?

(That seems a bit wasteful to me, given that the library is already non-blocking. And it sounds a big absurd, given that e.g. the Eio\_posix implementation of Eio is already operating a central Unix.select loop under the hood anyways. Is there any way to leverage on that?)

---

<div class="post-metadata">

**Author:** ![vog](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vog/32/6323_2.png) [@vog](https://discuss.ocaml.org/u/vog)\
**Post date:** [December 20, 2025, 2:35pm UTC](https://discuss.ocaml.org/t/waiting-in-eio-for-socket-data-without-reading-it/17615/2 "2025-12-20T14:35:11Z")

</div>

To answer my own question for future readers, I just found the function

[`Eio_unix.await_readable`](https://ocaml-multicore.github.io/eio/eio/Eio_unix/index.html#val-await_readable)

in the Eio documentation which I apparently completely overlooked so far.
