41
41
#define VIO_BUFFERED_READ 2 /* use buffered read */
42
42
#define VIO_READ_BUFFER_SIZE 16384 /* size of read buffer */
44
Vio* vio_new(int sd, enum enum_vio_type type, unsigned int flags);
44
Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags);
46
46
void vio_delete(Vio* vio);
47
47
int vio_close(Vio* vio);
48
void vio_reset(Vio* vio, enum enum_vio_type type, int sd, uint32_t flags);
49
size_t vio_read(Vio *vio, unsigned char * buf, size_t size);
50
size_t vio_read_buff(Vio *vio, unsigned char * buf, size_t size);
51
size_t vio_write(Vio *vio, const unsigned char * buf, size_t size);
48
void vio_reset(Vio* vio, enum enum_vio_type type, my_socket sd, uint32_t flags);
49
size_t vio_read(Vio *vio, uchar * buf, size_t size);
50
size_t vio_read_buff(Vio *vio, uchar * buf, size_t size);
51
size_t vio_write(Vio *vio, const uchar * buf, size_t size);
52
52
int vio_blocking(Vio *vio, bool onoff, bool *old_mode);
53
53
bool vio_is_blocking(Vio *vio);
54
54
/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */
66
66
/* Return last error number */
67
67
int vio_errno(Vio*vio);
68
68
/* Get socket number */
69
my_socket vio_fd(Vio*vio);
70
70
/* Remote peer's address and name in text form */
71
bool vio_peer_addr(Vio *vio, char *buf, uint16_t *port, size_t buflen);
72
bool vio_poll_read(Vio *vio, int timeout);
73
bool vio_peek_read(Vio *vio, unsigned int *bytes);
71
bool vio_peer_addr(Vio *vio, char *buf, uint16 *port, size_t buflen);
72
bool vio_poll_read(Vio *vio,uint timeout);
73
bool vio_peek_read(Vio *vio, uint *bytes);
75
75
void vio_end(void);
110
110
/* This structure is for every connection on both sides */
113
int sd; /* int - real or imaginary */
113
my_socket sd; /* my_socket - real or imaginary */
114
114
int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
115
115
struct sockaddr_storage local; /* Local internet address */
116
116
struct sockaddr_storage remote; /* Remote internet address */
124
124
/* function pointers. They are similar for socket/SSL/whatever */
125
125
void (*viodelete)(Vio*);
126
126
int32_t (*vioerrno)(Vio*);
127
size_t (*read)(Vio*, unsigned char *, size_t);
128
size_t (*write)(Vio*, const unsigned char *, size_t);
127
size_t (*read)(Vio*, uchar *, size_t);
128
size_t (*write)(Vio*, const uchar *, size_t);
129
129
int32_t (*vioblocking)(Vio*, bool, bool *);
130
130
bool (*is_blocking)(Vio*);
131
131
int32_t (*viokeepalive)(Vio*, bool);
135
135
bool (*should_retry)(Vio*);
136
136
bool (*was_interrupted)(Vio*);
137
137
int32_t (*vioclose)(Vio*);
138
void (*timeout)(Vio*, bool is_sndtimeo, int32_t timeout);
138
void (*timeout)(Vio*, uint32_t which, uint32_t timeout);
139
139
char *read_buffer; /* buffer for vio_read_buff */
141
141
#endif /* vio_violite_h_ */