MyroC Commands with Responses
write (int file_descriptor, const void * buffer, size_t num_bytes)
asks the operating system to send num_bytes from the
character array buffer through channel file_descriptor.
The operating system, not the user, controls when the data are sent
Once the operating system receives the request, write
returns, and user processing can continue.
In normal processing, the data will be sent eventually
Another program must ask the operating system to receive the data
read (int file_descriptor, void * buffer, size_t num_bytes)
asks the operating system for up to num_bytes from
the file_descriptor, and the data are copied to
The operating system places data that are present — up to num_bytes.
If fewer bytes of data are available, just those data are copied.
read returns the number of bytes actually copied
read is NON-blocking, so it returns quickly, whether or not any data are available.
How to use read to obtain the full num_bytes of data desired?