#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <poll.h>
#endif
#ifdef NET_ERR
-#include <stdlib.h>
/* Log helper function: create "host:port" string from socket address: */
static char *addr2str(const struct sockaddr *addr, socklen_t addrlen,
}
/* Write to socket or file descriptor: */
-ssize_t sendto_tm(int fd, void *buf, size_t len, int flags,
+ssize_t sendto_tm(int fd, const void *buf, size_t len, int flags,
const struct sockaddr *addr, socklen_t alen, int timeout) {
ssize_t r;
struct pollfd pfd;
* send_tm
* write_tm - functions and macros to write with timeout
*
+ * sendfile_tm - copy data from one file descriptor to another
+ *
*/
#ifndef NET_H_
* flags, addr and alen are ignored, and performance may be slightly
* inferior compared to a plain write() call.
*/
-extern ssize_t sendto_tm(int fd, void *buf, size_t len, int flags,
+extern ssize_t sendto_tm(int fd, const void *buf, size_t len, int flags,
const struct sockaddr *addr, socklen_t alen, int timeout);
/*
* Shorthand macros to closely match send() and write() prototypes: