RCFProto

- Main Page
- Classes
- Files

- File List

All Classes Functions Typedefs
Win32NamedPipeServerTransport.hpp
1
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18
19 #ifndef INCLUDE_RCF_WIN32NAMEDPIPESERVERTRANSPORT_HPP
20 #define INCLUDE_RCF_WIN32NAMEDPIPESERVERTRANSPORT_HPP
21
22 #include <RCF/AsioFwd.hpp>
23 #include <RCF/AsioServerTransport.hpp>
24 #include <RCF/Export.hpp>
25
26 namespace RCF {
27
28 class Win32NamedPipeServerTransport;
29
30 // Win32NamedPipeSessionState
31
32 class Win32NamedPipeSessionState : public AsioSessionState
33 {
34 public:
35 Win32NamedPipeSessionState(
36 Win32NamedPipeServerTransport & transport,
37 AsioIoService & ioService);
38
39 ~Win32NamedPipeSessionState();
40
41 const RemoteAddress & implGetRemoteAddress();
42
43 void implRead(char * buffer, std::size_t bufferLen);
44
45 void implWrite(const std::vector<ByteBuffer> & buffers);
46
47 void implWrite(AsioSessionState &toBeNotified, const char * buffer, std::size_t bufferLen);
48
49 void implAccept();
50
51 bool implOnAccept();
52
53 bool implIsConnected();
54
55 void implClose();
56
57 ClientTransportAutoPtr implCreateClientTransport();
58
59 void implTransferNativeFrom(ClientTransport & clientTransport);
60
61 static void closeSocket(AsioPipeHandlePtr socketPtr);
62
63 HANDLE getNativeHandle();
64
65 private:
66 AsioPipeHandlePtr mSocketPtr;
67 tstring mRemotePipeName;
68 NoRemoteAddress mRemoteAddress;
69
70 friend class Win32NamedPipeServerTransport;
71 friend class Win32NamedPipeImpersonator;
72 };
73
74 class RCF_EXPORT Win32NamedPipeServerTransport :
75 public AsioServerTransport
76 {
77 public:
78
79 Win32NamedPipeServerTransport(const tstring & pipeName);
80 ~Win32NamedPipeServerTransport();
81
82 TransportType getTransportType();
83
84 ServerTransportPtr clone();
85
86 AsioSessionStatePtr implCreateSessionState();
87 void implOpen();
88 ClientTransportAutoPtr implCreateClientTransport(
89 const Endpoint &endpoint);
90
91 tstring getPipeName() const;
92
93 void onServerStart(RcfServer & server);
94 void onServerStop(RcfServer & server);
95
96 void setSecurityAttributes(LPSECURITY_ATTRIBUTES pSec);
97
98 private:
99
100 friend class Win32NamedPipeSessionState;
101
102 tstring mPipeName;
103 HANDLE mPipeNameLock;
104
105 LPSECURITY_ATTRIBUTES mpSec;
106 };
107
108 class RCF_EXPORT Win32NamedPipeImpersonator
109 {
110 public:
111 Win32NamedPipeImpersonator();
112 Win32NamedPipeImpersonator(Win32NamedPipeSessionState & pipeSession);
113 ~Win32NamedPipeImpersonator();
114 void impersonate();
115 void revertToSelf() const;
116
117 private:
118
119 Win32NamedPipeSessionState & mPipeSession;
120 };
121
122 class RCF_EXPORT NullDacl
123 {
124 public:
125 NullDacl();
126 SECURITY_ATTRIBUTES mSa;
127 SECURITY_DESCRIPTOR mSd;
128 };
129
130 } // namespace RCF
131
132 #endif // ! INCLUDE_RCF_WIN32NAMEDPIPESERVERTRANSPORT_HPP