Listing 8: Server connect handler


nmpipe_eRetcode nmpipe_cListener::Connect(DWORD ServerConnectionTimeOut)
{
    BOOL bConnected = ConnectNamedPipe(hPipe, &Overlap);

    if (!bConnected) {

        DWORD rc = GetLastError();

        switch (rc) {
            case ERROR_PIPE_CONNECTED: break;

            case ERROR_IO_PENDING: 
                return BlockForIO(hEventShutdown,
                                  ServerConnectionTimeOut, 0);

            default:
            REPORT("Failure: ConnectNamedPipe() -- WinError = %u\n",
                GetLastError());
            return nmpipeError;
        }
    }

    return nmpipeOK;
}
//End of File