Windows named pipes in practice

后端 未结 2 1261
予麋鹿
予麋鹿 2021-01-05 16:49

With Windows named pipes, what is the proper way to use the CreateNamedPipe, ConnectNamedPipe, DisconnectNamedPipe, and CloseHan

2条回答
  •  温柔的废话
    2021-01-05 17:27

    I have managed to achieve what I wanted. I call CreateNamedPipe and CloseHandle exactly once per session, and I call DisconnectNamedPipe when my write fails, followed by another ConnectNamedPipe.

    The trick is to only call DisconnectNamedPipe when the pipe was actually connected. I called it every time I tried to connect "just to be sure" and it gave me strange errors.

    See also djgandy's answer for more information about pipes.

提交回复
热议问题