Monitor.t monitor listens for changes to the device list. A monitor is created by connecting to the kernel daemon through netlink (see
type filter =
Once the monitor is created, the devices that it listens to can be filtered using
Monitor.set_filter, specifying a list of
val create : ?source:netlink_source -> Context.t -> t
Create a monitor by connecting to the kernel daemon through netlink.
Udev: the monitor listens to the events emitted after udev has registered and configured the device. This is the absolutely recommended source for applications.
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.
Filtering & listening for devices
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.
timeout value is specified, the function blocks until a device event is available. A
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.