libjapi
0.3.2
Universal JSON API Library
|
Read or write a fixed number of bytes. More...
Functions | |
int | read_n (int fd, void *buf, size_t count) |
Read a fixed number of bytes from a file descriptor. More... | |
int | write_n (int fd, const void *buf, size_t count) |
Write a fixed number of bytes to a file descriptor. More... | |
Read or write a fixed number of bytes.
Use read_n() to read or write_n() to write a fixed number of bytes from or to a file descriptor.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
int read_n | ( | int | fd, |
void * | buf, | ||
size_t | count | ||
) |
Read a fixed number of bytes from a file descriptor.
read_n reads count bytes from a file descriptor fd into the buffer starting at buf. If the underlying read returns with less than count bytes read, read_n() calls read() again until all bytes are read or an error or EOF occurs.
fd | File descriptor |
buf | Pointer to the target buffer |
count | Number of bytes to copy |
int write_n | ( | int | fd, |
const void * | buf, | ||
size_t | count | ||
) |
Write a fixed number of bytes to a file descriptor.
write_n writes count bytes from the buffer buf to the file descriptor fd. If the underlying write() returns with less than count bytes written, write_n() calls write() again until all bytes are written or an error occurs.
fd | File descriptor |
buf | Pointer to the target buffer |
count | Number of bytes to copy |
Referenced by japi_pushsrv_sendmsg(), and japi_start_server().