00001
00002
00003
00004
00005
00006
00007
00008 #ifndef LINK_H
00009 #define LINK_H
00010
00044 #include "int_sizes.h"
00045
00046 #include <time.h>
00047 #include <limits.h>
00048 #include <stdio.h>
00049 #include <sys/types.h>
00050
00052 #define LINK_ADDRESS_MAX 48
00053
00055 #define LINK_PORT_ANY 0
00056
00058 #define LINK_FOREVER ((time_t)INT_MAX)
00059
00066 struct link * link_connect( const char *addr, int port, time_t stoptime );
00067
00074 struct link * link_serve( int port );
00075
00083 struct link * link_serve_address( const char *addr, int port );
00084
00090 struct link * link_accept( struct link *master, time_t stoptime );
00091
00101 int link_read( struct link *link, char *data, int length, time_t stoptime );
00102
00112 int link_read_avail( struct link *link, char *data, int length, time_t stoptime );
00113
00121 int link_write( struct link *link, const char *data, int length, time_t stoptime );
00122
00130 int link_usleep( struct link *link, int usec, int reading, int writing );
00131
00135 void link_close( struct link *link );
00136
00148 void link_window_set( int send_window, int recv_window );
00149
00156 void link_window_get( struct link *link, int *send_window, int *recv_window );
00157
00169 int link_readline( struct link *link, char *line, int length, time_t stoptime );
00170
00175 int link_fd( struct link *link );
00176
00177 int link_nonblocking( struct link *link, int onoff );
00178
00184 int link_address_local( struct link *link, char *addr, int *port );
00185
00191 int link_address_remote( struct link *link, char *addr, int *port );
00192
00193 INT64_T link_stream_to_buffer( struct link *link, char **buffer, time_t stoptime );
00194
00195 INT64_T link_stream_to_fd( struct link *link, int fd, INT64_T length, time_t stoptime );
00196 INT64_T link_stream_to_file( struct link *link, FILE *file, INT64_T length, time_t stoptime );
00197
00198 INT64_T link_stream_from_fd( struct link *link, int fd, INT64_T length, time_t stoptime );
00199 INT64_T link_stream_from_file( struct link *link, FILE *file, INT64_T length, time_t stoptime );
00200
00201 INT64_T link_soak( struct link *link, INT64_T length, time_t stoptime );
00202
00203 typedef enum {
00204 LINK_TUNE_INTERACTIVE,
00205 LINK_TUNE_BULK
00206 } link_tune_t;
00207
00208 int link_tune( struct link *link, link_tune_t mode );
00209
00210 #define LINK_READ 1
00211 #define LINK_WRITE 2
00212
00213 struct link_info {
00214 struct link *link;
00215 int events;
00216 int revents;
00217 };
00218
00219 int link_poll( struct link_info *array, int nlinks, int usec );
00220
00221
00222 #endif
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235