[C] Problem mit namedPipe und MsgWaitForMultipleObjectsEx

Buba235

Erfahrenes Mitglied
Hallo Leute!


Ich bin gerade dabei einen Server mit namedPipes zu schreiben. Leider gibt es bei mir immer ein paar kleinere Fehler. Das was mich aber richtig zum Verzweifeln bringt ist, dass die Funktion "MsgWaitForMultipleObjectsEx()" immer eine Access Violation wirft. Ich weiß woran es liegt, nur weiß ich nicht wie ich es umgehen könnte. Hier mal der Code:

Code:
hPipe = CreateNamedPipe ( lpszPipename,
                              PIPE_ACCESS_DUPLEX,       // read/write access
                              PIPE_TYPE_MESSAGE |       // message type pipe
                              PIPE_READMODE_MESSAGE |   // message-read mode
                              PIPE_WAIT,                // blocking mode
                              PIPE_UNLIMITED_INSTANCES, // max. instances
                              BUFSIZE,                  // output buffer size
                              BUFSIZE,                  // input buffer size
                              PIPE_TIMEOUT,             // client time-out
                              NULL);                    // no security attribute

    if (hPipe == INVALID_HANDLE_VALUE)
    {
        fprintf(stderr, "CreatePipe failed"); 
        return EXIT_FAILURE;
    }
    
    /* Trying connectnamedpipe in sample for CreateNamedPipe
       Wait for the client to connect; if it succeeds,
       the function returns a nonzero value. If the function returns
       zero, GetLastError returns ERROR_PIPE_CONNECTED.*/
    fConnected = MsgWaitForMultipleObjectsEx(MAXIMUM_WAIT_OBJECTS - 1, hPipe, 0, QS_ALLEVENTS, 0);

Der Fehler kommt, weil MsgWaitForMultipleObjectsEx leider nicht mit einer namedPipe als Handle umgehen kann. Ich brauch sie aber. Wie kann ich das umgehen? Habt ihr vielleicht ein paar Ideen?


Gruß
Buba
 
Zurück