1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; either
6
version 2 of the License, or (at your option) any later version.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public
14
License along with this library; if not, write to the Free
15
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20
* Purpose: include file for Vio that will work with C and C++
23
#ifndef vio_violite_h_
24
#define vio_violite_h_
26
#include "my_net.h" /* needed because of struct in_addr */
29
#include <Vio.h> /* Full VIO interface */
32
/* Simple vio interface in C; The functions are implemented in violite.c */
36
#endif /* __cplusplus */
40
struct st_vio; /* Only C */
41
typedef struct st_vio Vio;
44
enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET,
45
VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL};
47
Vio* vio_new(my_socket sd,
48
enum enum_vio_type type,
51
Vio* vio_new_win32pipe(HANDLE hPipe);
53
void vio_delete(Vio* vio);
56
* vio_read and vio_write should have the same semantics
57
* as read(2) and write(2).
59
int vio_read( Vio* vio,
61
int vio_write( Vio* vio,
65
* Whenever the socket is set to blocking mode or not.
67
int vio_blocking( Vio* vio,
69
my_bool vio_is_blocking( Vio* vio);
71
* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible.
73
int vio_fastsend( Vio* vio);
75
* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible.
77
int vio_keepalive( Vio* vio,
80
* Whenever we should retry the last read/write operation.
82
my_bool vio_should_retry( Vio* vio);
84
* When the workday is over...
86
int vio_close( Vio* vio);
88
* Short text description of the socket for those, who are curious..
90
const char* vio_description( Vio* vio);
92
/* Return the type of the connection */
93
enum enum_vio_type vio_type(Vio* vio);
95
/* Return last error number */
96
int vio_errno(Vio *vio);
98
/* Get socket number */
99
my_socket vio_fd(Vio *vio);
102
* Remote peer's address and name in text form.
104
my_bool vio_peer_addr(Vio * vio, char *buf);
106
/* Remotes in_addr */
108
void vio_in_addr(Vio *vio, struct in_addr *in);
110
/* Return 1 if there is data to be read */
111
my_bool vio_poll_read(Vio *vio,uint timeout);
116
#endif /* HAVE_VIO */
117
#endif /* vio_violite_h_ */