# Module `posix.poll`

Synchronous I/O Multiplexing.

Examine file descriptors for events, such as readyness for I/O.

## Functions

poll (fds[, timeout=-1]) | Wait for events on multiple file descriptors.
rpoll (fd[, timeout=-1]) | Wait for some event on a file descriptor.

## Functions

poll (fds[, timeout=-1])
  Wait for events on multiple file descriptors.

  ### Parameters:

  - fds table list of file descriptors
  - timeout int maximum timeout in milliseconds, or -1 to block indefinitely (default -1)

  ### Returns:

  int `0` if timed out, number of fd's ready if successful

  ### Or

  1. nil
  2. string error message
  3. int errnum

  ### See also:

  - poll(2)
  - rpoll
  - poll.lua
rpoll (fd[, timeout=-1])
  Wait for some event on a file descriptor. Based on a lua-l list post.

  ### Parameters:

  - fd int file descriptor
  - timeout int maximum timeout in milliseconds, or `-1` to block indefinitely (default -1)

  ### Returns:

  int `0` if timed out, number of fd's ready if successful

  ### Or

  1. nil
  2. error message
  3. int errnum

  ### See also:

  ### Usage:

      fh = io.open "one"
      while true do
        r = rpoll (fh, 500)
        if r == 0 then
          print 'timeout'
        elseif r == 1 then
          print (fh:read ())
        else
          print "finish!"
          break
        end
      end

generated by LDoc 1.5.0 Last updated 2023-06-16 20:19:12