44 #include <sys/types.h>
54 #define LINK_ADDRESS_MAX 48
57 #define LINK_PORT_ANY 0
60 #define LINK_FOREVER ((time_t)INT_MAX)
68 struct link *
link_connect(
const char *addr,
int port, time_t stoptime);
121 struct link *
link_accept(
struct link *master, time_t stoptime);
132 ssize_t
link_read(
struct link *link,
char *data,
size_t length, time_t stoptime);
143 ssize_t
link_read_avail(
struct link *link,
char *data,
size_t length, time_t stoptime);
152 ssize_t
link_write(
struct link *link,
const char *data,
size_t length, time_t stoptime);
162 ssize_t link_putlstring(
struct link *link,
const char *str,
size_t len, time_t stoptime);
171 #define link_putstring(l,s,t) (link_putlstring(l,s,strlen(s),t))
180 #define link_putliteral(l,s,t) (link_putlstring(l,s "",((sizeof(s))-1),t))
190 ssize_t
link_putfstring(
struct link *link,
const char *fmt, time_t stoptime, ...)
191 __attribute__ (( format(printf,2,4) )) ;
201 ssize_t
link_putvfstring(struct link *link, const
char *fmt, time_t stoptime, va_list va);
210 int link_usleep(struct link *link,
int usec,
int reading,
int writing);
212 int link_usleep_mask(struct link *link,
int usec, sigset_t *mask,
int reading,
int writing);
221 int link_sleep(struct link *link, time_t stoptime,
int reading,
int writing);
254 void link_window_get(struct link *link,
int *send_window,
int *recv_window);
267 int link_readline(struct link *link,
char *line,
size_t length, time_t stoptime);
273 int link_fd(struct link *link);
275 int link_keepalive(struct link *link,
int onoff);
277 int link_nonblocking(struct link *link,
int onoff);
302 ssize_t link_stream_to_buffer(struct link *link,
char **
buffer, time_t stoptime);
304 int64_t link_stream_to_fd(struct link *link,
int fd, int64_t length, time_t stoptime);
305 int64_t link_stream_to_file(struct link *link, FILE * file, int64_t length, time_t stoptime);
307 int64_t link_stream_from_fd(struct link *link,
int fd, int64_t length, time_t stoptime);
308 int64_t link_stream_from_file(struct link *link, FILE * file, int64_t length, time_t stoptime);
310 int64_t link_soak(struct link *link, int64_t length, time_t stoptime);
ssize_t link_putfstring(struct link *link, const char *fmt, time_t stoptime,...) __attribute__((format(printf
Write formatted data to a connection.
void link_window_get(struct link *link, int *send_window, int *recv_window)
Get the TCP window size actually allocated for this link.
int link_usleep(struct link *link, int usec, int reading, int writing)
Block until a link is readable or writable.
void link_detach(struct link *link)
Detach a link from the underlying file descriptor.
int link_buffer_empty(struct link *link)
Check whether a link has unread contents in its buffer.
int link_sleep(struct link *link, time_t stoptime, int reading, int writing)
Block until a link is readable or writable.
struct link * link
The link to be polled.
Definition: link.h:334
int link_address_remote(struct link *link, char *addr, int *port)
Return the remote address of the link in text format.
struct link * link_attach_to_file(FILE *file)
Turn a FILE* into a link.
struct link * link_accept(struct link *master, time_t stoptime)
Accept one connection.
void link_close(struct link *link)
Close a connection.
Data may be buffered to improve throughput of large transfers.
Definition: link.h:315
struct link * link_connect(const char *addr, int port, time_t stoptime)
Connect to a remote host.
int link_tune(struct link *link, link_tune_t mode)
Tune a link for interactive or bulk performance.
ssize_t link_read_avail(struct link *link, char *data, size_t length, time_t stoptime)
Read available data from a connection.
link_tune_t
Options for link performance tuning.
Definition: link.h:313
int revents
The events returned (LINK_READ or LINK_WRITE)
Definition: link.h:336
int link_fd(struct link *link)
Get the underlying file descriptor of a link.
void link_window_set(int send_window, int recv_window)
Set the TCP window size to be used for all links.
struct link * link_serve_address(const char *addr, int port)
Prepare to accept connections on one network interface.
Data is sent immediately to optimze interactive latency.
Definition: link.h:314
int link_readline(struct link *link, char *line, size_t length, time_t stoptime)
Read a line of text from a link.
struct link * link_serve(int port)
Prepare to accept connections.
struct link * link_serve_addrrange(const char *addr, int low, int high)
Prepare to accept connections on one network interface.
ssize_t link_read(struct link *link, char *data, size_t length, time_t stoptime)
Read data from a connection.
struct link * link_attach_to_fd(int fd)
Turn an fd into a link.
int link_poll(struct link_info *array, int nlinks, int msec)
Wait for a activity on a an array of links.
ssize_t link_write(struct link *link, const char *data, size_t length, time_t stoptime)
Write data to a connection.
struct link * link_serve_range(int low, int high)
Prepare to accept connections.
Activity structure passed to link_poll.
Definition: link.h:333
int events
The events to wait for (LINK_READ or LINK_WRITE)
Definition: link.h:335
int link_address_local(struct link *link, char *addr, int *port)
Return the local address of the link in text format.
ssize_t ssize_t link_putvfstring(struct link *link, const char *fmt, time_t stoptime, va_list va)
Write formatted data to a connection.