1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
19
#include <sys/socket.h>
22
namespace drizzle_plugin {
25
*@brief Virtual I/O layer, only used with TCP/IP sockets at the moment.
32
* @param[in] sd Descriptor to use.
38
*Close the connection.
39
*@returns 0 on success.
44
* Read some data from the remote end.
45
*@param[out] buf A buffer to write the new data to.
46
*@param[in] size The size of the buffer
47
*@returns The number of bytes read.
49
size_t read(unsigned char* buf, size_t size);
52
* Write some data to the remote end.
53
*@param[in] buf A buffer that contains the data to send.
54
*@param[in] size The size of the buffer
55
*@returns The number of bytes written.
57
size_t write(const unsigned char* buf, size_t size);
60
* Set device blocking mode.
61
*@param[in] set_blocking_mode Whether the device should block. true sets blocking mode, false clears it.
62
*@param[out] old_mode This will be set to the previous blocking mode.
63
*@returns 0 on success.
65
int blocking(bool set_blocking_mode, bool *old_mode);
68
* Enables fast sending.
69
* Setting this sets the TCP_NODELAY socket option.
70
*@returns 0 on succcess.
75
* Sets or clears the keepalive option.
76
*@param[in] set_keep_alive Whether to set or clear the flag. True Sets keepalive, false clears it.
77
*@returns 0 on success.
79
int32_t keepalive(bool set_keep_alive);
82
*@returns true if the caller should retry the last operation.
84
bool should_retry() const;
87
*@returns true if the last operation was interrupted.
89
bool was_interrupted() const;
92
*Gets the address details of the peer.
93
@param[out] buf Buffer that will recieve the peer address.
94
@param[out] port Port of remote end.
95
@param[in] buflen Size of buf.
96
@returns True on success, false otherwise.
98
bool peer_addr(char *buf, size_t buflen, uint16_t& port) const;
101
* Sets either the send, or recieve timeouts for the socket.
102
*@param[in] is_sndtimeo Set to true to change the send timeout, false to change the recieve timeout.
103
*@param[in] timeout The new timeout to set, in seconds.
105
void timeout(bool is_sndtimeo, int32_t timeout);
108
* Returns the last error code.
109
*@returns the last error code, as described in errno.h
111
int get_errno() const;
114
* Get the underlying descriptor this class is using.
115
*@returns The descriptor passed in to the constructor of this class.
121
int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
124
} /* namespace drizzle_plugin */