Interface MessageQueue.OnFileDescriptorEventListener
-
- Enclosing class:
- MessageQueue
public static interface MessageQueue.OnFileDescriptorEventListenerA listener which is invoked when file descriptor related events occur.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceMessageQueue.OnFileDescriptorEventListener.Events
-
Field Summary
Fields Modifier and Type Field Description static intEVENT_ERRORFile descriptor event: Indicates that the file descriptor encountered a fatal error.static intEVENT_INPUTFile descriptor event: Indicates that the file descriptor is ready for input operations, such as reading.static intEVENT_OUTPUTFile descriptor event: Indicates that the file descriptor is ready for output operations, such as writing.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intonFileDescriptorEvents(FileDescriptor fd, int events)Called when a file descriptor receives events.
-
-
-
Field Detail
-
EVENT_INPUT
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
trueto keep the listener active orfalseto 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_INPUTevent mask was specified when the listener was added.- See Also:
- Constant Field Values
-
EVENT_OUTPUT
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
trueto keep the listener active. Otherwise, it should returnfalseto remove the listener then re-register it later when it needs to write something else.This event will only be generated if the
EVENT_OUTPUTevent mask was specified when the listener was added.- See Also:
- Constant Field Values
-
EVENT_ERROR
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_ERRORevent mask was specified when the listener was added.- See Also:
- Constant Field Values
-
-
Method Detail
-
onFileDescriptorEvents
int onFileDescriptorEvents(FileDescriptor fd, int events)
Called when a file descriptor receives events.- Parameters:
fd- The file descriptor.events- The set of events that occurred: a combination of theEVENT_INPUT,EVENT_OUTPUT, andEVENT_ERRORevent masks.- Returns:
- The new set of events to watch, or 0 to unregister the listener.
- See Also:
EVENT_INPUT,EVENT_OUTPUT,EVENT_ERROR
-
-