~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/vio.h

  • Committer: Jay Pipes
  • Date: 2009-09-15 21:01:42 UTC
  • mto: (1126.2.5 merge)
  • mto: This revision was merged to the branch mainline in revision 1128.
  • Revision ID: jpipes@serialcoder-20090915210142-x8mwiqn1q0vzjspp
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
2
 
 
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.
6
 
 
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.
11
 
 
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 */
15
 
 
16
 
 
17
 
#pragma once
18
 
 
19
 
#include <sys/socket.h>
20
 
#include <cerrno>
21
 
 
22
 
namespace drizzle_plugin {
23
 
 
24
 
/**
25
 
 *@brief Virtual I/O layer, only used with TCP/IP sockets at the moment.
26
 
 */
27
 
class Vio
28
 
{
29
 
public:
30
 
  /**
31
 
   * Constructor. 
32
 
   * @param[in] sd Descriptor to use.
33
 
   */
34
 
  Vio(int sd);
35
 
  ~Vio();
36
 
 
37
 
  /**
38
 
   *Close the connection.
39
 
   *@returns 0 on success.
40
 
   */
41
 
  int close();
42
 
 
43
 
  /**
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.
48
 
   */
49
 
  size_t read(unsigned char* buf, size_t size);
50
 
  
51
 
  /**
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.
56
 
   */
57
 
  size_t write(const unsigned char* buf, size_t size);
58
 
 
59
 
  /**
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.
64
 
   */
65
 
  int blocking(bool set_blocking_mode, bool *old_mode);
66
 
 
67
 
  /**
68
 
   * Enables fast sending.
69
 
   * Setting this sets the TCP_NODELAY socket option.
70
 
   *@returns 0 on succcess.
71
 
   */
72
 
  int fastsend();
73
 
 
74
 
  /**
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.
78
 
   */
79
 
  int32_t keepalive(bool set_keep_alive);
80
 
 
81
 
  /**
82
 
   *@returns true if the caller should retry the last operation.
83
 
   */
84
 
  bool should_retry() const;
85
 
 
86
 
  /**
87
 
   *@returns true if the last operation was interrupted.
88
 
   */
89
 
  bool was_interrupted() const;
90
 
 
91
 
  /**
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.
97
 
   */
98
 
  bool peer_addr(char *buf, size_t buflen, uint16_t& port) const;
99
 
 
100
 
  /**
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.
104
 
   */
105
 
  void timeout(bool is_sndtimeo, int32_t timeout);
106
 
 
107
 
  /**
108
 
   * Returns the last error code.
109
 
   *@returns the last error code, as described in errno.h
110
 
   */
111
 
  int get_errno() const;
112
 
 
113
 
  /**
114
 
   * Get the underlying descriptor this class is using.
115
 
   *@returns The descriptor passed in to the constructor of this class.
116
 
   */
117
 
  int get_fd() const;
118
 
 
119
 
private:
120
 
  int sd;
121
 
  int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
122
 
};
123
 
 
124
 
} /* namespace drizzle_plugin */
125