No matching definitions.

tur/fd

stdlib/fd.tur

Fd: an opaque newtype over a POSIX file descriptor.

Since: stdlib-opaque-handle-types-plan, I/O sweep

defopaque

Fd

(Fd)
defn

fd->int

(fd->int [fd : Fd] :)

recover the raw :int file descriptor from an Fd.

fdthe Fd handle to unwrap

The underlying file descriptor as a plain :int.

(if (< (fd->int fd) 0) (handle-error))

Since: I/O sweep

defn

int->fd

(int->fd [n : int] :)

wrap a raw :int file descriptor as an Fd.

na raw file descriptor (e.g. 0/1/2 for stdin/stdout/stderr)

An Fd wrapping n.

(def stdin-fd (int->fd 0))

Since: I/O sweep

defn

fd-valid?

(fd-valid? [fd : Fd] :)

return true if the Fd is a real descriptor (>= 0).

fdthe Fd handle to test

true when the underlying fd is non-negative; false for the -1 error value.

(let [fd (async-socket-accept listen)]
    (when (fd-valid? fd) (serve fd)))

Since: I/O sweep