00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _pnamedpipe_h_
00021 #define _pnamedpipe_h_
00022
00023 #include <pclasses/pexport.h>
00024 #include <pclasses/piodevice.h>
00025 #include <string>
00026
00027 namespace P {
00028
00029 class NamedPipe;
00030
00032
00040 class PCORE_EXPORT NamedPipeServer {
00041 public:
00042 friend class NamedPipe;
00043
00045 NamedPipeServer() throw();
00046
00048 NamedPipeServer(const char* name) throw(IOError);
00049
00050 ~NamedPipeServer() throw();
00051
00052 void listen(const char* name) throw(IOError);
00053
00054 void close() throw(IOError);
00055
00057
00062 bool waitClient(unsigned int timeout) throw(IOError);
00063
00064 inline const std::string& path() const throw()
00065 { return m_name; }
00066
00067 protected:
00068
00069 io_handle_t accept() throw(IOError);
00070
00071 private:
00072 NamedPipeServer(const NamedPipeServer&);
00073 NamedPipeServer& operator=(const NamedPipeServer&);
00074
00075 io_handle_t m_handle;
00076 std::string m_name;
00077 };
00078
00080
00087 class PCORE_EXPORT NamedPipe: public IODevice {
00088 public:
00090 NamedPipe() throw();
00091
00093 NamedPipe(const char* name) throw(IOError);
00094
00096 NamedPipe(NamedPipeServer& srv) throw(IOError);
00097
00098 ~NamedPipe() throw();
00099
00101 void connect(const char* name) throw(IOError);
00102
00104 void close() throw(IOError);
00105
00106 size_t peek(char* buffer, size_t count) throw(IOError);
00107
00108 inline bool isSeekable() const throw()
00109 { return false; }
00110
00111 };
00112
00113 }
00114
00115 #endif