I am creating a named pipe connection between a .NET C# server app and a Win32 client app. In .NET C# it is possible to create a System.IO.StreamReader
object from named pipe server/client stream. Is anything similar available in Winapi to read from named pipe line by line??
Asked
Active
Viewed 583 times
1

Soumya Mahunt
- 2,148
- 12
- 30
-
1`PIPE_READMODE_MESSAGE` might help you. – 001 Nov 29 '20 at 13:41
-
There is no win32 function for reading file line by line.So you need to do some extra operations to process it into several lines.Refer to [Read text file (Unicode) in 'C' using native Win32](https://stackoverflow.com/questions/3614483/read-text-file-unicode-in-c-using-native-win32) – Zeus Nov 30 '20 at 02:25
1 Answers
1
Named pipes are special files, as such you read from them using the file IO API, namely ReadFile
, etc.
The MSDN has a complete example for opening and reading from a named pipe.

Konrad Rudolph
- 530,221
- 131
- 937
- 1,214
-
The issue with `ReadFile` is that it requires to specify size of buffer which isn't constant in my use hence I am looking for another solution. – Soumya Mahunt Nov 29 '20 at 13:56
-
4@SoumyaMahunt That’s simply how low level file IO (which is what the WinAPI provides) works. It *always* works like this. If you wan that, you’ll have to manage a dynamic buffer yourself, by reading fixed-sized chunks, determining the correct length and appending to a dynamically growing buffer. – Konrad Rudolph Nov 29 '20 at 16:07