Duplex named pipe hangs on a certain write

前端 未结 3 1317
被撕碎了的回忆
被撕碎了的回忆 2021-02-10 08:56

I have a C++ pipe server app and a C# pipe client app communicating via Windows named pipe (duplex, message mode, wait/blocking in separate read thread).

It all works fi

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-10 09:43

    It seems to me that what you are trying to do will rather not work as expected. Some time ago I was trying to do something that looked like your code and got similar results, the pipe just hanged and it was difficult to establish what had gone wrong.

    I would rather suggest to use client in very simple way:

    1. CreateFile
    2. Write request
    3. Read answer
    4. Close pipe.

    If you want to have two way communication with clients which are also able to receive unrequested data from server you should rather implement two servers. This was the workaround I used: here you can find sources.

提交回复
热议问题