00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
00134 struct sockaddr_storage local;
00135 struct sockaddr_storage remote;
00136 char *read_pos;
00137 char *read_end;
00138
00139 };
00140
00141 }
00142