Stay organized with collections
Save and categorize content based on your preferences.
MessageQueue.OnFileDescriptorEventListener
public
static
interface
MessageQueue.OnFileDescriptorEventListener
android.os.MessageQueue.OnFileDescriptorEventListener
|
A listener which is invoked when file descriptor related events occur.
Summary
Constants |
int |
EVENT_ERROR
File descriptor event: Indicates that the file descriptor encountered a
fatal error.
|
int |
EVENT_INPUT
File descriptor event: Indicates that the file descriptor is ready for input
operations, such as reading.
|
int |
EVENT_OUTPUT
File descriptor event: Indicates that the file descriptor is ready for output
operations, such as writing.
|
Constants
EVENT_ERROR
public static final int EVENT_ERROR
File descriptor event: Indicates that the file descriptor encountered a
fatal error.
File descriptor errors can occur for various reasons. One common error
is when the remote peer of a socket or pipe closes its end of the connection.
This event may be generated at any time regardless of whether the
EVENT_ERROR
event mask was specified when the listener was added.
Constant Value:
4
(0x00000004)
public static final int EVENT_INPUT
File descriptor event: Indicates that the file descriptor is ready for input
operations, such as reading.
The listener should read all available data from the file descriptor
then return true
to keep the listener active or false
to remove the listener.
In the case of a socket, this event may be generated to indicate
that there is at least one incoming connection that the listener
should accept.
This event will only be generated if the EVENT_INPUT
event mask was
specified when the listener was added.
Constant Value:
1
(0x00000001)
EVENT_OUTPUT
public static final int EVENT_OUTPUT
File descriptor event: Indicates that the file descriptor is ready for output
operations, such as writing.
The listener should write as much data as it needs. If it could not
write everything at once, then it should return true
to
keep the listener active. Otherwise, it should return false
to remove the listener then re-register it later when it needs to write
something else.
This event will only be generated if the EVENT_OUTPUT
event mask was
specified when the listener was added.
Constant Value:
2
(0x00000002)
Public methods
onFileDescriptorEvents
public abstract int onFileDescriptorEvents (FileDescriptor fd,
int events)
Called when a file descriptor receives events.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# MessageQueue.OnFileDescriptorEventListener\n\nAdded in [API level 23](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nMessageQueue.OnFileDescriptorEventListener\n==========================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/os/MessageQueue.OnFileDescriptorEventListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nMessageQueue.OnFileDescriptorEventListener\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------------------|\n| android.os.MessageQueue.OnFileDescriptorEventListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA listener which is invoked when file descriptor related events occur.\n\nSummary\n-------\n\n| ### Constants ||\n|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `int` | [EVENT_ERROR](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR) File descriptor event: Indicates that the file descriptor encountered a fatal error. |\n| `int` | [EVENT_INPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT) File descriptor event: Indicates that the file descriptor is ready for input operations, such as reading. |\n| `int` | [EVENT_OUTPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT) File descriptor event: Indicates that the file descriptor is ready for output operations, such as writing. |\n\n| ### Public methods ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract int` | ` `[onFileDescriptorEvents](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#onFileDescriptorEvents(java.io.FileDescriptor,%20int))`(`[FileDescriptor](/reference/java/io/FileDescriptor)` fd, int events) ` Called when a file descriptor receives events. |\n\nConstants\n---------\n\n### EVENT_ERROR\n\nAdded in [API level 23](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int EVENT_ERROR\n```\n\nFile descriptor event: Indicates that the file descriptor encountered a\nfatal error.\n\n\nFile descriptor errors can occur for various reasons. One common error\nis when the remote peer of a socket or pipe closes its end of the connection.\n\n\nThis event may be generated at any time regardless of whether the\n[EVENT_ERROR](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR) event mask was specified when the listener was added.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nConstant Value:\n\n4\n(0x00000004)\n\n\n### EVENT_INPUT\n\nAdded in [API level 23](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int EVENT_INPUT\n```\n\nFile descriptor event: Indicates that the file descriptor is ready for input\noperations, such as reading.\n\n\nThe listener should read all available data from the file descriptor\nthen return `true` to keep the listener active or `false`\nto remove the listener.\n\n\nIn the case of a socket, this event may be generated to indicate\nthat there is at least one incoming connection that the listener\nshould accept.\n\n\nThis event will only be generated if the [EVENT_INPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT) event mask was\nspecified when the listener was added.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nConstant Value:\n\n1\n(0x00000001)\n\n\n### EVENT_OUTPUT\n\nAdded in [API level 23](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int EVENT_OUTPUT\n```\n\nFile descriptor event: Indicates that the file descriptor is ready for output\noperations, such as writing.\n\n\nThe listener should write as much data as it needs. If it could not\nwrite everything at once, then it should return `true` to\nkeep the listener active. Otherwise, it should return `false`\nto remove the listener then re-register it later when it needs to write\nsomething else.\n\n\nThis event will only be generated if the [EVENT_OUTPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT) event mask was\nspecified when the listener was added.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nConstant Value:\n\n2\n(0x00000002)\n\n\nPublic methods\n--------------\n\n### onFileDescriptorEvents\n\nAdded in [API level 23](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract int onFileDescriptorEvents (FileDescriptor fd, \n int events)\n```\n\nCalled when a file descriptor receives events.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fd` | `FileDescriptor`: The file descriptor. This value cannot be `null`. \u003cbr /\u003e |\n| `events` | `int`: The set of events that occurred: a combination of the [EVENT_INPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT), [EVENT_OUTPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT), and [EVENT_ERROR](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR) event masks. Value is either `0` or a combination of [EVENT_INPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT), [EVENT_OUTPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT), and [EVENT_ERROR](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR) \u003cbr /\u003e |\n\n| Returns ||\n|-------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `int` | The new set of events to watch, or 0 to unregister the listener. Value is either `0` or a combination of [EVENT_INPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT), [EVENT_OUTPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT), and [EVENT_ERROR](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR) \u003cbr /\u003e |\n\n**See also:**\n\n- [EVENT_INPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT)\n- [EVENT_OUTPUT](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT)\n- [EVENT_ERROR](/reference/android/os/MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR)"]]