Urgent Named Pipe issue
-
I am trying to use named pipe to transfer data between two process. I have called the following code
HANDLE hPipe; LPTSTR lpszPipename = "\\\\.\\pipe\\DataTransferPipe"; hPipe = CreateNamedPipe( lpszPipename, // pipe name 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 1024, // output buffer size 1024, // input buffer size 18000, // client time-out NULL); // no security attribute if (hPipe == INVALID_HANDLE_VALUE) { MessageBox("Error creating named pipe", "Named Pipe Error" , MB_OK); return; } bool bConnected = ConnectNamedPipe(hPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
I want the system to be that if no client connect for say 3 sec the call ConnectNamedPipe should return false. Is this possible....how. In the above code it just locks on the ConnectNamedPipe call -
I am trying to use named pipe to transfer data between two process. I have called the following code
HANDLE hPipe; LPTSTR lpszPipename = "\\\\.\\pipe\\DataTransferPipe"; hPipe = CreateNamedPipe( lpszPipename, // pipe name 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 1024, // output buffer size 1024, // input buffer size 18000, // client time-out NULL); // no security attribute if (hPipe == INVALID_HANDLE_VALUE) { MessageBox("Error creating named pipe", "Named Pipe Error" , MB_OK); return; } bool bConnected = ConnectNamedPipe(hPipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
I want the system to be that if no client connect for say 3 sec the call ConnectNamedPipe should return false. Is this possible....how. In the above code it just locks on the ConnectNamedPipe callBOOL SetNamedPipeHandleState( HANDLE hNamedPipe, // handle to named pipe LPDWORD lpMode, // pointer to new pipe mode LPDWORD lpMaxCollectionCount, // pointer to maximum collection count LPDWORD lpCollectDataTimeout // pointer to time-out value );