Add a file descriptor to the currently active channel.
BPS_API int bps_add_fd(int fd, int io_events, int(*io_handler)(int, int, void *), void *data)
The file descriptor to start monitoring.
The I/O conditions to monitor for.
The I/O callback that is called whenever I/O conditions are met.
User supplied data that will be given to the I/O callback as the third argument.
Library:libbps (For the qcc command, use the -l bps option to link against this library)
Call the function when a service wants to include a file descriptor in the active channel's set of file descriptors. At that time, the channel includes the supplied file descriptor into the set of file descriptors that it is monitoring. When the I/O conditions, specified in io_events, are met then the channel calls the io_handler callback supplied.
An error occurs when you add a file descriptor that was already added to the channel.
You can perform a bitwise OR to bps_io_events_t enumerations and pass it as a second argument to specify the I/O conditions that the channel monitors.
For example, the code that follows shows when you want to monitor for input and supply no user data:
The code that follows shows how to monitor for input and errors, with a channel specific data "service":
The io_handler callback is called whenever io_events I/O conditions are present for the file descriptor. The first argument will be the file descriptor, the second argument will be one or more bps_io_events_t enumerated values to indicate which conditions are present. The third argument is the user data. If the io_handler callback returns BPS_FAILURE, io_handler callback will no longer be called to handle the specified condtions.
BPS_SUCCESS if the fd (file descriptor) was successfully added to the channel, BPS_FAILURE with the errno value set otherwise.
- See also:
Last modified: 2014-09-30