socket_sendfile(3)

socket_sendfile3

Send a file over a tcp socket

Usage

#include <socket.h>

int socket_sendfile(int out, int in, uint32 offset,
uint32 bytes);

Overview

socket_sendfile sends bytes bytes starting at offset in the file in to the socket connected to file descriptor out.

The socket must be connected.

Note that the underlying sendfile system call is system specific and currently only implemented on Linux. On other operating systems, it is emulated with a read/write loop.

Return value

socket_sendfile returns 0 if the data was sent successfully. If not, it returns -1 and sets errno appropriately.

Examples

#include <socket.h>
#include <open.h>

int s;
char ip[4];
uint16 p;
int fd = open_read("/etc/passwd");

s = socket_tcp4();
socket_connect4(s,ip,p);
socket_sendfile(s,fd,0,23);

From libowfat-dev 0.10-1 in Debian 3.0 (Woody). Parsed by carta from the page's man source.