![]() |
| | #1 |
| Registered User Join Date: May 2007
Posts: 8
| Detecting EOF in Named Pipes I've got a problem with Named Pipe under Windows. I've created a (waiting and duplex) Named Pipe with CreateNamedPipe() and ConnectNamedPipe(). On the client side I've connected to this with CreateFile() and write an amount of data to this pipe. How can the client tell the server, that the end of data is reached. When I try SetEndOfFile() I got the error code ERROR_INVALID_PARAMETER. And closing the handle is inacceptable because after the client wrote its data, it want to read the answer, so I need the handle. Junktyz. |
| Junktyz is offline | |
| | #2 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Yes, SetEndOfFile only works on "real" files (that is those on a disk/memory card/tape and such). To indicate end of file on a pipe, you have two choices: 1. Close the pipe. 2. Introduce a protocol where you send the size of the file at the beginning [to make it robust, you probably need some way to ensure that the data you receive is ACTUALLY the size of the file, and not something else!] -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #3 |
| Registered User Join Date: May 2007
Posts: 8
| I've been afraid of an answer like that . But thanks. Because the length of the data must not be known at the beginning, I implement a Brickwall Stream. The brickwall is a byte array. When closing the output stream this data is send and when reading this brickwall in the input stream, EOF is recognized. |
| Junktyz is offline | |
![]() |
| Tags |
| file, named pipes, pipes |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting an error with OpenGL: collect2: ld returned 1 exit status | Lorgon Jortle | C++ Programming | 6 | 05-08-2009 08:18 PM |
| error: ‘struct tcphdr’ has no member named ‘th_win’ | nasim751 | C Programming | 2 | 04-22-2008 12:07 PM |
| error: ‘struct tcphdr’ has no member named ‘th_seq | nasim751 | C Programming | 2 | 04-19-2008 12:06 AM |
| Deletion of open named pipes | sparkymat | Linux Programming | 4 | 11-07-2007 10:46 AM |
| Named Pipes with .NET? | michl | C# Programming | 2 | 04-28-2003 12:54 AM |