C++: Implementing Named Pipes using the Win32 API

后端 未结 2 2023
北海茫月
北海茫月 2020-12-25 14:34

I\'m trying to implement named pipes in C++, but either my reader isn\'t reading anything, or my writer isn\'t writing anything (or both). Here\'s my reader:



        
相关标签:
2条回答
  • 2020-12-25 14:40

    A named pipe client can open the named pipe with CreateFile -- but the named pipe server needs to use CreateNamedPipe to create the named pipe. After it's created the named pipe, the server uses ConnectNamedPipe to wait for a client to connect. Only after the client has connected should the server do a blocking read like your call to ReadFile.

    0 讨论(0)
  • 2020-12-25 14:50

    You must use CreateNamedPipe() to create the server end of a named pipe. Be sure to specify a non-zero buffer size, zero (documented by MSDN as 'use system default buffer size') doesn't work. MSDN has decent samples for a multi-threaded client&server.

    0 讨论(0)
提交回复
热议问题