I/O handling APIs.
More...
Go to the source code of this file.
|
| int | qio_wait_readable (int fd, int timeoutms) |
| | Wait until a file descriptor becomes readable.
|
| int | qio_wait_writable (int fd, int timeoutms) |
| | Wait until a file descriptor is ready for writing.
|
| ssize_t | qio_read (int fd, void *buf, size_t nbytes, int timeoutms) |
| | Read from a file descriptor.
|
| ssize_t | qio_write (int fd, const void *buf, size_t nbytes, int timeoutms) |
| | Write to a file descriptor.
|
| off_t | qio_send (int outfd, int infd, off_t nbytes, int timeoutms) |
| | Transfer data between file descriptors.
|
| ssize_t | qio_gets (int fd, char *buf, size_t bufsize, int timeoutms) |
| | Read a line from a file descriptor into the buffer until a terminating newline or EOF.
|
| ssize_t | qio_puts (int fd, const char *str, int timeoutms) |
| | Write a string and a trailing newline to a file descriptor.
|
| ssize_t | qio_printf (int fd, int timeoutms, const char *format,...) |
| | Write formatted output to a file descriptor.
|
I/O handling APIs.
Definition in file qio.c.
◆ MAX_IOSEND_SIZE
| #define MAX_IOSEND_SIZE (32 * 1024) |
Definition at line 44 of file qio.c.
◆ qio_wait_readable()
| int qio_wait_readable |
( |
int | fd, |
|
|
int | timeoutms ) |
Wait until a file descriptor becomes readable.
- Parameters
-
| fd | file descriptor |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- 1 if readable, 0 on timeout, -1 if an error occurred.
- Note
- timeoutms can be used to set the maximum wait time for a socket descriptor.
Definition at line 59 of file qio.c.
◆ qio_wait_writable()
| int qio_wait_writable |
( |
int | fd, |
|
|
int | timeoutms ) |
Wait until a file descriptor is ready for writing.
- Parameters
-
| fd | file descriptor |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- 1 if writable, 0 on timeout, -1 if an error occurred.
Definition at line 87 of file qio.c.
◆ qio_read()
| ssize_t qio_read |
( |
int | fd, |
|
|
void * | buf, |
|
|
size_t | nbytes, |
|
|
int | timeoutms ) |
Read from a file descriptor.
- Parameters
-
| fd | file descriptor |
| buf | data buffer to write into |
| nbytes | number of bytes to read from the file descriptor and write into buf |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- the number of bytes read if successful, 0 on timeout, -1 for error.
Definition at line 118 of file qio.c.
◆ qio_write()
| ssize_t qio_write |
( |
int | fd, |
|
|
const void * | buf, |
|
|
size_t | nbytes, |
|
|
int | timeoutms ) |
Write to a file descriptor.
- Parameters
-
| fd | file descriptor |
| buf | data buffer to read from |
| nbytes | number of bytes to write to the file descriptor from buf |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- the number of bytes written if successful, 0 on timeout, -1 for error.
Definition at line 158 of file qio.c.
◆ qio_send()
| off_t qio_send |
( |
int | outfd, |
|
|
int | infd, |
|
|
off_t | nbytes, |
|
|
int | timeoutms ) |
Transfer data between file descriptors.
- Parameters
-
| outfd | output file descriptor |
| infd | input file descriptor |
| nbytes | the number of bytes to copy between file descriptors. 0 means transfer until end of infd. |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- the number of bytes transferred if successful, 0 on timeout, -1 for error.
Definition at line 198 of file qio.c.
◆ qio_gets()
| ssize_t qio_gets |
( |
int | fd, |
|
|
char * | buf, |
|
|
size_t | bufsize, |
|
|
int | timeoutms ) |
Read a line from a file descriptor into the buffer until a terminating newline or EOF.
Newline characters (CR, LF) are not stored in the buffer.
- Parameters
-
| fd | file descriptor |
| buf | data buffer pointer |
| bufsize | buffer size |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- the number of bytes read if successful, 0 on timeout, -1 for error.
- Note
- The return value is not the length of the stored string. It is the number of bytes read from the file descriptor, so newline characters are counted even though they are not stored.
Definition at line 255 of file qio.c.
◆ qio_puts()
| ssize_t qio_puts |
( |
int | fd, |
|
|
const char * | str, |
|
|
int | timeoutms ) |
Write a string and a trailing newline to a file descriptor.
- Parameters
-
| fd | file descriptor |
| str | string pointer |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
- Returns
- the number of bytes written including trailing newline characters if successful, 0 for timeout and -1 for errors.
Definition at line 299 of file qio.c.
◆ qio_printf()
| ssize_t qio_printf |
( |
int | fd, |
|
|
int | timeoutms, |
|
|
const char * | format, |
|
|
| ... ) |
Write formatted output to a file descriptor.
- Parameters
-
| fd | file descriptor |
| timeoutms | wait timeout milliseconds. 0 for no wait, -1 for infinite wait |
| format | format string |
- Returns
- the number of bytes written including trailing newline characters if successful, 0 for timeout and -1 for errors.
Definition at line 323 of file qio.c.