Changeset 1833
- Timestamp:
- 14/09/2007 22:25:42 (4 years ago)
- Location:
- box/chris/general/lib/server
- Files:
-
- 2 edited
-
WinNamedPipeStream.cpp (modified) (8 diffs)
-
WinNamedPipeStream.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/chris/general/lib/server/WinNamedPipeStream.cpp
r1784 r1833 26 26 27 27 #include "MemLeakFindOn.h" 28 29 std::string WinNamedPipeStream::sPipeNamePrefix = "\\\\.\\pipe\\"; 28 30 29 31 // -------------------------------------------------------------------------- … … 73 75 // 74 76 // Function 75 // Name: WinNamedPipeStream::Accept(const char*Name)77 // Name: WinNamedPipeStream::Accept(const std::string& rName) 76 78 // Purpose: Creates a new named pipe with the given name, 77 79 // and wait for a connection on it … … 79 81 // 80 82 // -------------------------------------------------------------------------- 81 void WinNamedPipeStream::Accept(const wchar_t* pName)83 void WinNamedPipeStream::Accept(const std::string& rName) 82 84 { 83 85 if (mSocketHandle != INVALID_HANDLE_VALUE || mIsConnected) … … 86 88 } 87 89 88 mSocketHandle = CreateNamedPipeW( 89 pName, // pipe name 90 std::string socket = sPipeNamePrefix + rName; 91 92 mSocketHandle = CreateNamedPipeA( 93 socket.c_str(), // pipe name 90 94 PIPE_ACCESS_DUPLEX | // read/write access 91 95 FILE_FLAG_OVERLAPPED, // enabled overlapped I/O … … 101 105 if (mSocketHandle == INVALID_HANDLE_VALUE) 102 106 { 103 BOX_ERROR("Failed to CreateNamedPipe W(" << pName<< "): " <<107 BOX_ERROR("Failed to CreateNamedPipeA(" << socket << "): " << 104 108 GetErrorMessage(GetLastError())); 105 109 THROW_EXCEPTION(ServerException, SocketOpenError) … … 110 114 if (!connected) 111 115 { 112 BOX_ERROR("Failed to ConnectNamedPipe(" << pName<< "): " <<116 BOX_ERROR("Failed to ConnectNamedPipe(" << socket << "): " << 113 117 GetErrorMessage(GetLastError())); 114 118 Close(); … … 157 161 // 158 162 // Function 159 // Name: WinNamedPipeStream::Connect(const char*Name)163 // Name: WinNamedPipeStream::Connect(const std::string& rName) 160 164 // Purpose: Opens a connection to a listening named pipe 161 165 // Created: 2005/12/07 162 166 // 163 167 // -------------------------------------------------------------------------- 164 void WinNamedPipeStream::Connect(const wchar_t* pName)168 void WinNamedPipeStream::Connect(const std::string& rName) 165 169 { 166 170 if (mSocketHandle != INVALID_HANDLE_VALUE || mIsConnected) … … 168 172 THROW_EXCEPTION(ServerException, SocketAlreadyOpen) 169 173 } 170 171 mSocketHandle = CreateFileW( 172 pName, // pipe name 174 175 std::string socket = sPipeNamePrefix + rName; 176 177 mSocketHandle = CreateFileA( 178 socket.c_str(), // pipe name 173 179 GENERIC_READ | // read and write access 174 180 GENERIC_WRITE, -
box/chris/general/lib/server/WinNamedPipeStream.h
r631 r1833 28 28 29 29 // server side - create the named pipe and listen for connections 30 void Accept(const wchar_t*Name);30 void Accept(const std::string& rName); 31 31 32 32 // client side - connect to a waiting server 33 void Connect(const wchar_t*Name);33 void Connect(const std::string& rName); 34 34 35 35 // both sides … … 62 62 bool mIsServer; 63 63 bool mIsConnected; 64 65 static std::string sPipeNamePrefix; 64 66 }; 65 67
Note: See TracChangeset
for help on using the changeset viewer.
