channel_read - read a message from a channel
#include <magenta/syscalls.h>
mx_status_t mx_channel_read(mx_handle_t handle, uint32_t flags,
void* bytes,
uint32_t num_bytes, uint32_t* actual_bytes
mx_handle_t* handles,
uint32_t num_handles, uint32_t* actual_handles);
channel_read() attempts to read the first message from the channel specified by handle into the provided bytes and/or handles buffers.
The parameters num_bytes and num_handles are used to specify the size of the read buffers.
Channel messages may contain both byte data and handle payloads and may only be read in their entirety. Partial reads are not possible.
channel_read() returns NO_ERROR on success, if actual_bytes and actual_handles (if non-NULL), contain the exact number of bytes and count of handles read.
ERR_BAD_HANDLE handle is not a valid handle.
ERR_WRONG_TYPE handle is not a channel handle.
ERR_INVALID_ARGS If any of bytes, handles, actual_bytes, or actual_handles are non-NULL and an invalid pointer.
ERR_ACCESS_DENIED handle does not have MX_RIGHT_READ.
ERR_SHOULD_WAIT The channel contained no messages to read.
ERR_REMOTE_CLOSED The other side of the channel is closed.
ERR_NO_MEMORY (Temporary) Failure due to lack of memory.
ERR_BUFFER_TOO_SMALL The provided bytes or handles buffers are too small (in which case, the minimum sizes necessary to receive the message will be written to actual_bytes and actual_handles, provided they are non-NULL). If flags has MX_CHANNEL_READ_MAY_DISCARD set, then the message is discarded.
num_handles and actual_handles are counts of the number of elements in the handles array, not its size in bytes.
handle_close, handle_duplicate, handle_replace, handle_wait_one, handle_wait_many, channel_create, channel_write.