Reference

socket_sendfile(3)

send a file over a TCP socket

NAME

socket_sendfile - send a file over a TCP socket

SYNTAX

#include <socket.h>

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

DESCRIPTION

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.

EXAMPLE

#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);

SEE ALSO

socket_send6(3)