Go to the documentation of this file.
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)
61 #define LINK_NOWAIT ((time_t)INT_MIN)
69 struct link *
link_connect(
const char *addr,
int port, time_t stoptime);
128 struct link *
link_accept(
struct link *parent, time_t stoptime);
150 ssize_t
link_read(
struct link *link,
char *data,
size_t length, time_t stoptime);
161 ssize_t
link_read_avail(
struct link *link,
char *data,
size_t length, time_t stoptime);
170 ssize_t
link_write(
struct link *link,
const char *data,
size_t length, time_t stoptime);
180 ssize_t link_putlstring(
struct link *link,
const char *str,
size_t len, time_t stoptime);
189 #define link_putstring(l,s,t) (link_putlstring(l,s,strlen(s),t))
198 #define link_putliteral(l,s,t) (link_putlstring(l,s "",((sizeof(s))-1),t))
208 ssize_t
link_printf(
struct link *link, time_t stoptime,
const char *fmt, ...)
209 __attribute__ (( format(printf,3,4) )) ;
219 ssize_t
link_vprintf(struct link *link, time_t stoptime, const
char *fmt, va_list va);
228 int link_usleep(struct link *link,
int usec,
int reading,
int writing);
230 int link_usleep_mask(struct link *link,
int usec, sigset_t *mask,
int reading,
int writing);
239 int link_sleep(struct link *link, time_t stoptime,
int reading,
int writing);
272 void link_window_get(struct link *link,
int *send_window,
int *recv_window);
285 int link_readline(struct link *link,
char *line,
size_t length, time_t stoptime);
291 int link_fd(struct link *link);
310 int link_keepalive(struct link *link,
int onoff);
312 int link_nonblocking(struct link *link,
int onoff);
337 ssize_t link_stream_to_buffer(struct link *link,
char **
buffer, time_t stoptime);
339 int64_t link_stream_to_fd(struct link *link,
int fd, int64_t length, time_t stoptime);
340 int64_t link_stream_to_file(struct link *link, FILE * file, int64_t length, time_t stoptime);
342 int64_t link_stream_from_fd(struct link *link,
int fd, int64_t length, time_t stoptime);
343 int64_t link_stream_from_file(struct link *link, FILE * file, int64_t length, time_t stoptime);
345 int64_t link_soak(struct link *link, int64_t length, time_t stoptime);
384 int errno_is_temporary(
int e);
ssize_t link_write(struct link *link, const char *data, size_t length, time_t stoptime)
Write data to a connection.
Activity structure passed to link_poll.
Definition: link.h:368
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.
struct link * link_attach_to_file(FILE *file)
Turn a FILE* into a link.
struct link * link
The link to be polled.
Definition: link.h:369
void link_close(struct link *link)
Close a connection.
@ LINK_TUNE_BULK
Data may be buffered to improve throughput of large transfers.
Definition: link.h:350
struct link * link_serve_range(int low, int high)
Prepare to accept connections.
struct link * link_connect(const char *addr, int port, time_t stoptime)
Connect to a remote host.
int link_readline(struct link *link, char *line, size_t length, time_t stoptime)
Read a line of text from a link.
int link_sleep(struct link *link, time_t stoptime, int reading, int writing)
Block until a link is readable or writable.
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_output(struct link *link, size_t size)
Enable output buffering for link_printf.
int revents
The events returned (LINK_READ or LINK_WRITE)
Definition: link.h:371
@ LINK_TUNE_INTERACTIVE
Data is sent immediately to optimze interactive latency.
Definition: link.h:349
int link_flush_output(struct link *link)
Flush buffered output from link_printf.
int link_ssl_wrap_accept(struct link *lnk, const char *key, const char *cert)
Wrap an accepted link with an ssl context.
int link_using_ssl(struct link *link)
Whether the link is using ssl.
int link_address_local(struct link *link, char *addr, int *port)
Return the local address of the link in text format.
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:348
void link_window_get(struct link *link, int *send_window, int *recv_window)
Get the TCP window size actually allocated for this link.
int events
The events to wait for (LINK_READ or LINK_WRITE)
Definition: link.h:370
ssize_t link_printf(struct link *link, time_t stoptime, const char *fmt,...) __attribute__((format(printf
Write formatted data to a connection.
int link_fd(struct link *link)
Get the underlying file descriptor of a link.
int link_tune(struct link *link, link_tune_t mode)
Tune a link for interactive or bulk performance.
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.
int link_buffer_empty(struct link *link)
Check whether a link has unread contents in its buffer.
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 ssize_t link_vprintf(struct link *link, time_t stoptime, const char *fmt, va_list va)
Write formatted data to a connection.
struct link * link_accept(struct link *parent, time_t stoptime)
Accept one connection.
int link_address_remote(struct link *link, char *addr, int *port)
Return the remote address of the link in text format.
ssize_t link_read(struct link *link, char *data, size_t length, time_t stoptime)
Read data from a connection.
int link_ssl_wrap_connect(struct link *link)
Wrap a connect link with an ssl context and state.