Represents a uloop handle instance as returned by handle().
const handle = uloop.handle(…);
handle.fileno();
handle.handle();
handle.delete();- Source
- See
Methods
delete() → {void}
Unregisters the uloop handle.
This method unregisters the uloop handle from the uloop event loop and frees any associated resources. After calling this method, the handle instance should no longer be used.
Call this method before closing the underlying descriptor. The event loop does not notice a closed descriptor and keeps the handle alive until it is deleted.
A handle knows its descriptor only by number, device and inode, and checks them when it is deleted. A handle whose descriptor was closed is disabled for good once the check fails, once uloop rejects the removal, or once another handle is created on the same number. It then stays allocated and ignores events. If the number was reused for the same file opened anew, for example the same path or device node, and a watcher outside of this module, such as the application that embeds ucode, watches it, the check cannot tell the two files apart, and deleting the old handle removes the other watcher's entry.
This function does not return a value.
// Unregister the uloop handle and free associated resources
handle.delete();
printf("Handle deleted successfully\n");- Source
fileno() → {number}
Returns the file descriptor number.
This method returns the file descriptor number associated with the underlying handle, which might refer to a socket or file instance.
The file descriptor number associated with the handle.
// Get the file descriptor number associated with the uloop handle
const fd = handle.fileno();
printf("File descriptor number: %d\n", fd);- Source
handle() → {module:fs.file|module:fs.proc|module:socket.socket}
Returns the underlying file or socket instance.
This method returns the underlying file or socket instance associated with the uloop handle.
The underlying file or socket instance associated with the handle.
// Get the associated file or socket instance
const fileOrSocket = handle.handle();
printf("Handle: %s\n", fileOrSocket); // e.g. <socket 0x5> or <fs.proc …>- Source