Skip to content

Most visited

Recently visited

navigation
added in API level 23

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.

Public methods

abstract int onFileDescriptorEvents(FileDescriptor fd, int events)

Called when a file descriptor receives events.

Constants

EVENT_ERROR

added in API level 23
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)

EVENT_INPUT

added in API level 23
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

added in API level 23
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

added in API level 23
int onFileDescriptorEvents (FileDescriptor fd, 
                int events)

Called when a file descriptor receives events.

Parameters
fd FileDescriptor: The file descriptor.

This value must never be null.

events int: The set of events that occurred: a combination of the EVENT_INPUT, EVENT_OUTPUT, and EVENT_ERROR event masks.

Returns
int The new set of events to watch, or 0 to unregister the listener.

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)