Ignore:
Timestamp:
01/02/13 06:43:16 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Cleaned up and simplified the code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/win32/LocalSocket.h

    r21 r22  
    5151public:
    5252    /**
    53      * Create a concrete pipe name from the given user-specified name.
     53     * Create a concrete pipe path from the given user-specified name.
    5454     *
    5555     * @param dest the destination buffer, which should be at least
    5656     * 256 bytes long.
    5757     */
    58     static void setupName(char* dest, const char* name);
     58    static void setupPath(char* dest, const char* name);
    5959
    6060    /**
     
    9090protected:
    9191    /**
    92      * Connect the named pipe with the current handle of this object.
    93      *
    94      * @return whether the connection succeeded. If not, it may be a
    95      * failure, which is then indicated, or it may be an overlapped
    96      * operation which needs to wait.
     92     * Connect the client socket to the server.
    9793     */
    98     bool connect(Overlapped* overlapped);
     94    bool connect(const char* path);
    9995
    10096    friend class LocalAcceptor;
     
    106102//------------------------------------------------------------------------------
    107103
    108 inline void LocalSocket::setupName(char* dest, const char* name)
     104inline void LocalSocket::setupPath(char* dest, const char* name)
    109105{
    110106    snprintf(dest, 256, "\\\\.\\pipe\\%s", name);
     
    134130//------------------------------------------------------------------------------
    135131
    136 inline bool LocalSocket::connect(Overlapped* overlapped)
     132inline bool LocalSocket::connect(const char* path)
    137133{
    138     bool result = connectNamedPipe(handle, overlapped);
    139     if (!result && overlapped==0) {
     134    handle = CreateFile(path, GENERIC_READ|GENERIC_WRITE,
     135                        0, 0, OPEN_EXISTING,
     136                        FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, 0);
     137    if (handle==0) {
    140138        setErrorCode(GetLastError());
    141139    }
    142     return result;
     140
     141    return handle!=0;
    143142}
    144143
Note: See TracChangeset for help on using the changeset viewer.