C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-19-2009, 12:44 AM   #1
Registered User
 
Join Date: May 2007
Posts: 8
Detecting EOF in Named Pipes

Hi,

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   Reply With Quote
Old 05-19-2009, 02:20 AM   #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   Reply With Quote
Old 05-19-2009, 02:44 AM   #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   Reply With Quote
Reply

Tags
file, named pipes, pipes

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 08:45 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22