source: box/trunk/lib/server/WinNamedPipeStream.h @ 2318

Revision 2318, 1.7 KB checked in by chris, 4 years ago (diff)

Remove Win32 command socket thread, as it has caused too much trouble.

Handle command socket on Win32 the same as all other platforms, removing
#ifdefs from BackupDaemon?.

Will replace this thread with regular but not excessive command socket
polling using timers in future.

Change error messages when command socket comms fail to make them clearer.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    WinNamedPipeStream.h
5//              Purpose: I/O stream interface for Win32 named pipes
6//              Created: 2005/12/07
7//
8// --------------------------------------------------------------------------
9
10#if ! defined WINNAMEDPIPESTREAM__H && defined WIN32
11#define WINNAMEDPIPESTREAM__H
12
13#include "IOStream.h"
14
15// --------------------------------------------------------------------------
16//
17// Class
18//              Name:    WinNamedPipeStream
19//              Purpose: I/O stream interface for Win32 named pipes
20//              Created: 2003/07/31
21//
22// --------------------------------------------------------------------------
23class WinNamedPipeStream : public IOStream
24{
25public:
26        WinNamedPipeStream();
27        WinNamedPipeStream(HANDLE hNamedPipe);
28        ~WinNamedPipeStream();
29
30        // server side - create the named pipe and listen for connections
31        // use WinNamedPipeListener to do this instead.
32
33        // client side - connect to a waiting server
34        void Connect(const std::string& rName);
35
36        // both sides
37        virtual int Read(void *pBuffer, int NBytes, 
38                int Timeout = IOStream::TimeOutInfinite);
39        virtual void Write(const void *pBuffer, int NBytes);
40        virtual void WriteAllBuffered();
41        virtual void Close();
42        virtual bool StreamDataLeft();
43        virtual bool StreamClosed();
44
45protected:
46        void MarkAsReadClosed()  {mReadClosed  = true;}
47        void MarkAsWriteClosed() {mWriteClosed = true;}
48
49private:
50        WinNamedPipeStream(const WinNamedPipeStream &rToCopy) 
51                { /* do not call */ }
52
53        HANDLE mSocketHandle;
54        HANDLE mReadableEvent;
55        OVERLAPPED mReadOverlap;
56        uint8_t mReadBuffer[4096];
57        size_t  mBytesInBuffer;
58        bool mReadClosed;
59        bool mWriteClosed;
60        bool mIsServer;
61        bool mIsConnected;
62
63public:
64        static std::string sPipeNamePrefix;
65};
66
67#endif // WINNAMEDPIPESTREAM__H
Note: See TracBrowser for help on using the repository browser.