liburing icon indicating copy to clipboard operation
liburing copied to clipboard

How to MSG_PEEK with io_uring

Open sumeetchhetri opened this issue 3 years ago • 2 comments

Is it possible to peek pending socket data without having to register a read call to the uring? Found no examples available for the same.

sumeetchhetri avatar Jul 29 '22 05:07 sumeetchhetri

Ok, so to provide the context here, imagine a client library like libpq (postgresql client) that wraps most of the socket reading part within the api calls, we can very easily register the libpq client socket to a select/poll/epoll backend and interact with postgresql. But in the case of io_uring, there is no mechanism to be able to do the same thing, what is needed here is an event like 'io_uring_prep_recv' [imagine io_uring_prep_recv_peek] which just notifies of pending data and never actually reads it.

sumeetchhetri avatar Aug 01 '22 06:08 sumeetchhetri

Specify MSG_PEEK in the flags of your recv request (should work), or use a io_uring_prep_poll with EPOLLIN to be notified of data

davidzeng0 avatar Sep 25 '22 03:09 davidzeng0