Named Pipe

1.            
    CreateNamedPipe                                    CreateFile
Access/Open Mode--The open handle's read/write permission to pipeGENERIC_WRITE|GENERIC_READ
Type Mode--controls WriteFile uses Byte or Message typeN/A
Read Mode--controls ReadFile uses Byte or Message typeN/A

    The type modes must be the same for all instances of a pipe.

2. 
ServerClient
CreateNamedPipeCreateFile
ConnectNamedPipeWaitNamedPipe
ReadFile/WriteFile    ReadFile/WriteFile 
DisconnectNamedPipeCloseHandle

   
3. FILE_FLAG_WRITE_THROUGH affects only write operations to byte-type pipes between pipe clients and pipe servers on different computers.
    The write-through mode of a pipe handle cannot be changed after the pipe handle has been created. 
    The write-through mode can be different for server and client handles to the same pipe instance.

4. For a message-type pipe, the read mode can be different for server and client handles to the same pipe instance.

6. For a pipe client, a pipe handle returned by CreateFile is always in byte-read mode initially.

7. The nonblocking-wait mode is supported for compatibility with Microsoft® LAN Manager version 2.0. This mode should not be used to achieve overlapped input and output (I/O) with named pipes.

8. A client that is forced off a pipe by DisconnectNamedPipe must still use the function to close its end of the pipe. This is because the pipe exists as long as a server or client process has an open handle to the pipe.

9. ConnectNamedPipe can be used to connect to a newly created pipe instance or an instance that was previously connected to another client process.(The hPipe that is disconnected but not closed by CloseHandle)

10. ConnectNamedPipe will return
        @ERROR_NO_DATA --server did not call DisconnectNamedPipe and the client has closed its handle.
        @ERROR_PIPE_CONNECTED--if a client connects in the interval between the call to CreateNamedPipe and the call to ConnectNamedPipe. Or server did not call DisconnectNamedPipe and the client has not closed its handle.
        @ERROR_PIPE_LISTENING--no client  is connected while server in nonblocking mode.

11. server's ReadFile will return ERROR_BROKEN_PIPE if the client uses CloseHandle to close the pipe, which be used to notify the server the connection can over now.

转载于:https://www.cnblogs.com/jeffreytan/archive/2006/06/08/420654.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值