corosio's socket types (tcp_socket, udp_socket, local_stream_socket, local_datagram_socket) only expose readiness through read_some / write_some, which require a non-empty buffer. There is no way to suspend until a socket is readable or writable without actually moving bytes.
This blocks a common integration pattern: wrapping a C library that owns the I/O (it does its own recv/send on the fd in O_NONBLOCK mode) and just needs a notification of readiness. Today the only workaround would be a 1-byte peek, which consumes data from the stream.
Proposal
Add an awaitable wait operation, e.g.:
enum class wait_type { read, write, error };
auto [ec] = co_await sock.wait(wait_type::read);
Equivalent to asio's socket_base::wait_read / wait_write / wait_error and async_wait. On the reactor backends this is a one-shot EPOLLIN / EPOLLOUT / EVFILT_READ etc. registration with no buffer; on IOCP it can be emulated via WSAEventSelect or a zero-byte WSARecv (a real Windows pattern for this use case).
Would unblock wrapping O_NONBLOCK C APIs (e.g. libssh, libpq async mode, custom protocol parsers) with corosio as the reactor.
corosio's socket types (
tcp_socket,udp_socket,local_stream_socket,local_datagram_socket) only expose readiness throughread_some/write_some, which require a non-empty buffer. There is no way to suspend until a socket is readable or writable without actually moving bytes.This blocks a common integration pattern: wrapping a C library that owns the I/O (it does its own
recv/sendon the fd inO_NONBLOCKmode) and just needs a notification of readiness. Today the only workaround would be a 1-byte peek, which consumes data from the stream.Proposal
Add an awaitable wait operation, e.g.:
Equivalent to asio's
socket_base::wait_read/wait_write/wait_errorandasync_wait. On the reactor backends this is a one-shotEPOLLIN/EPOLLOUT/EVFILT_READetc. registration with no buffer; on IOCP it can be emulated viaWSAEventSelector a zero-byteWSARecv(a real Windows pattern for this use case).Would unblock wrapping
O_NONBLOCKC APIs (e.g. libssh, libpq async mode, custom protocol parsers) with corosio as the reactor.