Library
Module
Module type
Parameter
Class
Class type
Device monitoring.
A Monitor.t
monitor listens for changes to the device list. A monitor is created by connecting to the kernel daemon through netlink (see Monitor.create
).
Once the monitor is created, the devices that it listens to can be filtered using Monitor.set_filter
, specifying a list of filter
values.
val create : ?source:netlink_source -> Context.t -> t
Create a monitor by connecting to the kernel daemon through netlink.
By default, source
is Udev
: the monitor listens to the events emitted after udev has registered and configured the device. This is the absolutely recommended source for applications.
A source
of Kernel
means that the monitor receives the events directly after the kernel has seen the device. The device has not yet been configured by udev and might not be usable at all. Do not use this, unless you know what you are doing.
val start : t -> unit
Start a monitor. A monitor m
will not receive events until Monitor.start m
is called. This function does nothing if called on an already started monitor.
Poll for a device event. Monitor.receive_device ~timeout m
will block until a device event is received, or after timeout
seconds, in which case the Timeout
exception is raised.
If no timeout
value is specified, the function blocks until a device event is available. A timeout
of 0.
means that the function just polls and will never block.
val set_receive_buffer_size : t -> int -> unit
Set the receive buffer size, in bytes.
val fd : t -> Unix.file_descr
Return the file descriptor associated with the monitor.