00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__net__Pipe_H__
00010 #define __libutilxx__sella__net__Pipe_H__
00011
00012 #include "../../common.h"
00013 #include "UnixSocket.h"
00014
00015 #include <sys/socket.h>
00016
00017 namespace sella {
00018 namespace net {
00019 class Pipe;
00020 }
00021 }
00022
00023 class sella::net::Pipe {
00024 public:
00025 typedef std::shared_ptr<Pipe> shared;
00026 typedef Pipe *ptr;
00027
00028 static const size_t ReadSizeDefault = 65536;
00029
00030 public:
00031 Pipe(bool nonBlock = true) throw (SocketException);
00032 Pipe(const Pipe &sock) = delete;
00033 virtual ~Pipe();
00034 void operator=(const Pipe &sock) = delete;
00035
00036 ssize_t write(const void *data, size_t len) throw (SocketException);
00037 ssize_t write(const std::string &data) throw (SocketException);
00038 ssize_t write(const std::vector<uint8_t> &data) throw (SocketException);
00039 ssize_t read(void *data, size_t len) throw (SocketException);
00040 ssize_t read(std::string &data, size_t len = ReadSizeDefault) throw (SocketException);
00041 ssize_t read(std::vector<uint8_t> &data, size_t len = ReadSizeDefault) throw (SocketException);
00042
00043 int getWriteFD(void);
00044 int getReadFD(void);
00045
00046 static const Pipe::shared shared_ptr(bool nonBlock = true) throw (SocketException);
00047
00048 protected:
00049 int fd[2];
00050 };
00051
00052 #endif
00053
00054
00055
00056