PageRenderTime 23ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/mordor/streams/namedpipe.h

http://github.com/mozy/mordor
C Header | 54 lines | 29 code | 15 blank | 10 comment | 0 complexity | 4a0792f975c38096b59c48019d3f409c MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #ifndef __MORDOR_NAMEDPIPE_STREAM_H__
  2. #define __MORDOR_NAMEDPIPE_STREAM_H__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include "handle.h"
  5. namespace Mordor {
  6. class NamedPipeStream : public HandleStream
  7. {
  8. public:
  9. typedef boost::shared_ptr<NamedPipeStream> ptr;
  10. enum Flags {
  11. READ = PIPE_ACCESS_INBOUND,
  12. WRITE = PIPE_ACCESS_OUTBOUND,
  13. READWRITE = PIPE_ACCESS_DUPLEX
  14. };
  15. public:
  16. // Currently this class only supports the Server side of a named pipe connection
  17. // It creates a new pipe based on the passed name argument.
  18. // By default a byte-mode pipe is created (PIPE_TYPE_BYTE), but the pipeModeFlags
  19. // argument can be used to create a message-mode pipe.
  20. NamedPipeStream(const std::string &name, Flags flags = READWRITE, IOManager *ioManager = NULL, Scheduler *scheduler = NULL, DWORD pipeModeFlags = (DWORD)-1);
  21. NamedPipeStream(const std::wstring &name, Flags flags = READWRITE, IOManager *ioManager = NULL, Scheduler *scheduler = NULL, DWORD pipeModeFlags = (DWORD)-1);
  22. bool supportsRead() { return m_supportsRead; }
  23. bool supportsWrite() { return m_supportsWrite; }
  24. bool supportsSeek() { return false; }
  25. void close(CloseType type = BOTH);
  26. // Close a connected client if any, but leave the named pipe open.
  27. // Should be called after processing a client request and before
  28. // calling accept to wait for the next connection.
  29. void disconnectClient();
  30. // Accept will put the fiber to sleep until a client connection arrives
  31. // Throws OperationAbortedException if another fiber calls cancelAccept()
  32. void accept();
  33. void cancelAccept();
  34. private:
  35. void init(const std::wstring &name, Flags flags, DWORD pipeModeFlags, IOManager *ioManager, Scheduler *scheduler);
  36. bool m_supportsRead, m_supportsWrite;
  37. };
  38. }
  39. #endif