summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-10-17 12:48:05 +0000
committerChris Wilson <chris+github@qwirx.com>2007-10-17 12:48:05 +0000
commit4165c30332ba148735d726eed8cdd500a1376fbf (patch)
tree844a0613cd2c02721e5e8b8441bb9531212a981e /lib
parent34ecfa2e8afdfbdd171c0d838a878994721c940f (diff)
Prepend the system-required prefix to the named pipe name from the
configuration file. (merges [1833])
Diffstat (limited to 'lib')
-rw-r--r--lib/server/WinNamedPipeStream.cpp26
-rw-r--r--lib/server/WinNamedPipeStream.h6
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/server/WinNamedPipeStream.cpp b/lib/server/WinNamedPipeStream.cpp
index d7e90793..fedb57d8 100644
--- a/lib/server/WinNamedPipeStream.cpp
+++ b/lib/server/WinNamedPipeStream.cpp
@@ -26,6 +26,8 @@
#include "MemLeakFindOn.h"
+std::string WinNamedPipeStream::sPipeNamePrefix = "\\\\.\\pipe\\";
+
// --------------------------------------------------------------------------
//
// Function
@@ -72,21 +74,23 @@ WinNamedPipeStream::~WinNamedPipeStream()
// --------------------------------------------------------------------------
//
// Function
-// Name: WinNamedPipeStream::Accept(const char* Name)
+// Name: WinNamedPipeStream::Accept(const std::string& rName)
// Purpose: Creates a new named pipe with the given name,
// and wait for a connection on it
// Created: 2005/12/07
//
// --------------------------------------------------------------------------
-void WinNamedPipeStream::Accept(const wchar_t* pName)
+void WinNamedPipeStream::Accept(const std::string& rName)
{
if (mSocketHandle != INVALID_HANDLE_VALUE || mIsConnected)
{
THROW_EXCEPTION(ServerException, SocketAlreadyOpen)
}
- mSocketHandle = CreateNamedPipeW(
- pName, // pipe name
+ std::string socket = sPipeNamePrefix + rName;
+
+ mSocketHandle = CreateNamedPipeA(
+ socket.c_str(), // pipe name
PIPE_ACCESS_DUPLEX | // read/write access
FILE_FLAG_OVERLAPPED, // enabled overlapped I/O
PIPE_TYPE_BYTE | // message type pipe
@@ -100,7 +104,7 @@ void WinNamedPipeStream::Accept(const wchar_t* pName)
if (mSocketHandle == INVALID_HANDLE_VALUE)
{
- BOX_ERROR("Failed to CreateNamedPipeW(" << pName << "): " <<
+ BOX_ERROR("Failed to CreateNamedPipeA(" << socket << "): " <<
GetErrorMessage(GetLastError()));
THROW_EXCEPTION(ServerException, SocketOpenError)
}
@@ -109,7 +113,7 @@ void WinNamedPipeStream::Accept(const wchar_t* pName)
if (!connected)
{
- BOX_ERROR("Failed to ConnectNamedPipe(" << pName << "): " <<
+ BOX_ERROR("Failed to ConnectNamedPipe(" << socket << "): " <<
GetErrorMessage(GetLastError()));
Close();
THROW_EXCEPTION(ServerException, SocketOpenError)
@@ -156,20 +160,22 @@ void WinNamedPipeStream::Accept(const wchar_t* pName)
// --------------------------------------------------------------------------
//
// Function
-// Name: WinNamedPipeStream::Connect(const char* Name)
+// Name: WinNamedPipeStream::Connect(const std::string& rName)
// Purpose: Opens a connection to a listening named pipe
// Created: 2005/12/07
//
// --------------------------------------------------------------------------
-void WinNamedPipeStream::Connect(const wchar_t* pName)
+void WinNamedPipeStream::Connect(const std::string& rName)
{
if (mSocketHandle != INVALID_HANDLE_VALUE || mIsConnected)
{
THROW_EXCEPTION(ServerException, SocketAlreadyOpen)
}
+
+ std::string socket = sPipeNamePrefix + rName;
- mSocketHandle = CreateFileW(
- pName, // pipe name
+ mSocketHandle = CreateFileA(
+ socket.c_str(), // pipe name
GENERIC_READ | // read and write access
GENERIC_WRITE,
0, // no sharing
diff --git a/lib/server/WinNamedPipeStream.h b/lib/server/WinNamedPipeStream.h
index aded2d59..6acd48f6 100644
--- a/lib/server/WinNamedPipeStream.h
+++ b/lib/server/WinNamedPipeStream.h
@@ -27,10 +27,10 @@ public:
~WinNamedPipeStream();
// server side - create the named pipe and listen for connections
- void Accept(const wchar_t* Name);
+ void Accept(const std::string& rName);
// client side - connect to a waiting server
- void Connect(const wchar_t* Name);
+ void Connect(const std::string& rName);
// both sides
virtual int Read(void *pBuffer, int NBytes,
@@ -61,6 +61,8 @@ private:
bool mWriteClosed;
bool mIsServer;
bool mIsConnected;
+
+ static std::string sPipeNamePrefix;
};
#endif // WINNAMEDPIPESTREAM__H