Drizzled Public API Documentation

vio.h
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 
00017 #pragma once
00018 
00019 #include <sys/socket.h>
00020 #include <cerrno>
00021 
00022 namespace drizzle_plugin
00023 {
00024 
00028 class Vio
00029 {
00030 public:
00035   Vio(int sd);
00036   ~Vio();
00037 
00042   int close();
00043 
00050   size_t read(unsigned char* buf, size_t size);
00051   
00058   size_t write(const unsigned char* buf, size_t size);
00059 
00066   int blocking(bool set_blocking_mode, bool *old_mode);
00067 
00073   int fastsend();
00074 
00080   int32_t keepalive(bool set_keep_alive);
00081 
00085   bool should_retry() const;
00086 
00090   bool was_interrupted() const;
00091 
00099   bool peer_addr(char *buf, uint16_t *port, size_t buflen) const;
00100 
00106   void timeout(bool is_sndtimeo, int32_t timeout);
00107 
00112   int get_errno() const;
00113 
00118   int get_fd() const;
00119 
00123   char *get_read_pos() const;
00124 
00128   char *get_read_end() const;
00129 
00130 private:
00131   bool closed;
00132   int sd;
00133   int fcntl_mode; /* Buffered fcntl(sd,F_GETFL) */
00134   struct sockaddr_storage local; /* Local internet address */
00135   struct sockaddr_storage remote; /* Remote internet address */
00136   char *read_pos; /* start of unfetched data in the read buffer */
00137   char *read_end; /* end of unfetched data */
00138 
00139 };
00140 
00141 } /* namespace drizzle_plugin */
00142