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_putfstring(
struct link *link,
const char *fmt, time_t stoptime, ...)
209 __attribute__ (( format(printf,2,4) )) ;
219 ssize_t
link_putvfstring(struct link *link, const
char *fmt, time_t stoptime, 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);
300 int link_keepalive(struct link *link,
int onoff);
302 int link_nonblocking(struct link *link,
int onoff);
327 ssize_t link_stream_to_buffer(struct link *link,
char **
buffer, time_t stoptime);
329 int64_t link_stream_to_fd(struct link *link,
int fd, int64_t length, time_t stoptime);
330 int64_t link_stream_to_file(struct link *link, FILE * file, int64_t length, time_t stoptime);
332 int64_t link_stream_from_fd(struct link *link,
int fd, int64_t length, time_t stoptime);
333 int64_t link_stream_from_file(struct link *link, FILE * file, int64_t length, time_t stoptime);
335 int64_t link_soak(struct link *link, int64_t length, time_t stoptime);
374 int errno_is_temporary(
int e);
int link_using_ssl(struct link *link)
Whether the link is using ssl.
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:359
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.
void link_close(struct link *link)
Close a connection.
Data may be buffered to improve throughput of large transfers.
Definition: link.h:340
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:338
int revents
The events returned (LINK_READ or LINK_WRITE)
Definition: link.h:361
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:339
int link_ssl_wrap_connect(struct link *link)
Wrap a connect link with an ssl context and state.
struct link * link_accept(struct link *parent, time_t stoptime)
Accept one connection.
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.
int link_ssl_wrap_accept(struct link *l, const char *key, const char *cert)
Wrap an accepted link with an ssl context.
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:358
int events
The events to wait for (LINK_READ or LINK_WRITE)
Definition: link.h:360
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.