Changeset 1833


Ignore:
Timestamp:
14/09/2007 22:25:42 (4 years ago)
Author:
chris
Message:

Prepend the system-required prefix to the named pipe name from the
configuration file.

Location:
box/chris/general/lib/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • box/chris/general/lib/server/WinNamedPipeStream.cpp

    r1784 r1833  
    2626 
    2727#include "MemLeakFindOn.h" 
     28 
     29std::string WinNamedPipeStream::sPipeNamePrefix = "\\\\.\\pipe\\"; 
    2830 
    2931// -------------------------------------------------------------------------- 
     
    7375// 
    7476// Function 
    75 //              Name:    WinNamedPipeStream::Accept(const char* Name) 
     77//              Name:    WinNamedPipeStream::Accept(const std::string& rName) 
    7678//              Purpose: Creates a new named pipe with the given name, 
    7779//                      and wait for a connection on it 
     
    7981// 
    8082// -------------------------------------------------------------------------- 
    81 void WinNamedPipeStream::Accept(const wchar_t* pName) 
     83void WinNamedPipeStream::Accept(const std::string& rName) 
    8284{ 
    8385        if (mSocketHandle != INVALID_HANDLE_VALUE || mIsConnected)  
     
    8688        } 
    8789 
    88         mSocketHandle = CreateNamedPipeW(  
    89                 pName,                     // pipe name  
     90        std::string socket = sPipeNamePrefix + rName; 
     91 
     92        mSocketHandle = CreateNamedPipeA(  
     93                socket.c_str(),            // pipe name  
    9094                PIPE_ACCESS_DUPLEX |       // read/write access  
    9195                FILE_FLAG_OVERLAPPED,      // enabled overlapped I/O 
     
    101105        if (mSocketHandle == INVALID_HANDLE_VALUE) 
    102106        { 
    103                 BOX_ERROR("Failed to CreateNamedPipeW(" << pName << "): " << 
     107                BOX_ERROR("Failed to CreateNamedPipeA(" << socket << "): " << 
    104108                        GetErrorMessage(GetLastError())); 
    105109                THROW_EXCEPTION(ServerException, SocketOpenError) 
     
    110114        if (!connected) 
    111115        { 
    112                 BOX_ERROR("Failed to ConnectNamedPipe(" << pName << "): " << 
     116                BOX_ERROR("Failed to ConnectNamedPipe(" << socket << "): " << 
    113117                        GetErrorMessage(GetLastError())); 
    114118                Close(); 
     
    157161// 
    158162// Function 
    159 //              Name:    WinNamedPipeStream::Connect(const char* Name) 
     163//              Name:    WinNamedPipeStream::Connect(const std::string& rName) 
    160164//              Purpose: Opens a connection to a listening named pipe 
    161165//              Created: 2005/12/07 
    162166// 
    163167// -------------------------------------------------------------------------- 
    164 void WinNamedPipeStream::Connect(const wchar_t* pName) 
     168void WinNamedPipeStream::Connect(const std::string& rName) 
    165169{ 
    166170        if (mSocketHandle != INVALID_HANDLE_VALUE || mIsConnected)  
     
    168172                THROW_EXCEPTION(ServerException, SocketAlreadyOpen) 
    169173        } 
    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  
    173179                GENERIC_READ |  // read and write access  
    174180                GENERIC_WRITE,  
  • box/chris/general/lib/server/WinNamedPipeStream.h

    r631 r1833  
    2828 
    2929        // server side - create the named pipe and listen for connections 
    30         void Accept(const wchar_t* Name); 
     30        void Accept(const std::string& rName); 
    3131 
    3232        // client side - connect to a waiting server 
    33         void Connect(const wchar_t* Name); 
     33        void Connect(const std::string& rName); 
    3434 
    3535        // both sides 
     
    6262        bool mIsServer; 
    6363        bool mIsConnected; 
     64 
     65        static std::string sPipeNamePrefix; 
    6466}; 
    6567 
Note: See TracChangeset for help on using the changeset viewer.