Home

EVFILTREAD

EVFILT_READ is a filter type used by the kqueue I/O event notification mechanism on BSD-derived systems, including macOS and FreeBSD. It monitors a file descriptor for readability, delivering an event when data is available to read without blocking. The filter may also indicate end-of-file, such as when the other end of a pipe or socket has closed.

When a kevent with EVFILT_READ is triggered, the event’s data field typically reports how much data is

Usage involves creating a kqueue, then registering the target file descriptor with EVFILT_READ using flags such

EVFILT_READ is commonly used for sockets, pipes, and other non-regular-file descriptors in event-driven I/O. It is

available
to
read.
The
EV_EOF
flag
is
set
if
the
read
side
has
reached
end-of-file.
Readability
semantics
vary
by
descriptor
type:
for
sockets
and
pipes,
it
reflects
buffered
data;
for
regular
files,
readability
behavior
can
differ
and
may
be
always
available
in
some
contexts.
as
EV_ADD
and
EV_ENABLE;
optional
flags
like
EV_CLEAR
enable
edge-triggered
notifications.
Applications
wait
for
events
with
kevent,
and
upon
return
examine
the
event.
If
EV_EOF
is
set,
the
peer
has
closed
the
connection
and
the
descriptor
may
be
closed
or
removed
from
monitoring.
Otherwise,
data
can
be
read
from
the
descriptor
up
to
the
amount
indicated
by
the
data
field,
using
non-blocking
I/O
as
appropriate,
and
the
event
may
be
re-armed
according
to
the
chosen
semantics.
a
core
component
of
the
BSD
kqueue
API
and
differs
from
Linux’s
epoll
in
platform
and
semantics,
making
it
a
key
tool
for
scalable
network
servers
and
similar
applications
on
supported
systems.