I/O


 #include <cio/io.h> 

Functions

ssize_t cio_read (int fd, void *buf, size_t bufsize)
ssize_t cio_write (int fd, const void *buf, size_t bufsize)
ssize_t cio_sendfile (int out_fd, int in_fd, off_t *offset, size_t count)

Function Documentation

ssize_t cio_read ( int  fd,
void *  buf,
size_t  bufsize 
)

Read from a file descriptor.

Parameters:
fd file descriptor
buf buffer
bufsize maximum number of bytes to read
Return values:
>0 the number of bytes read
0 on end-of-file
-1 on error with errno set
Precondition:
fd should be in non-blocking mode
See also:
read(2)
ssize_t cio_sendfile ( int  out_fd,
int  in_fd,
off_t *  offset,
size_t  count 
)

Transfer data between file descriptors. If offset is not NULL, it will be updated according to the number of bytes transferred.

Parameters:
out_fd target file descriptor
in_fd source file descriptor
offset pointer to file offset or NULL
count maximum number of bytes to transfer
Return values:
>=0 the number of bytes transferred
-1 on error with errno set
Precondition:
fd should be in non-blocking mode
Note:
any restrictions imposed by the platform's sendfile() implementation apply also to this function
Bug:
if in_fd returns EAGAIN (and there is no other I/O going on), this function busyloops
See also:
sendfile(2)
ssize_t cio_write ( int  fd,
const void *  buf,
size_t  bufsize 
)

Write to a file descriptor.

Parameters:
fd file descriptor
buf buffer
bufsize maximum number of bytes to write
Return values:
>0 the number of bytes written
0 on end-of-file
-1 on error with errno set
Precondition:
fd should be in non-blocking mode
See also:
write(2)