创建的时候设置:
HANDLE CreateNamedPipe( LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
或者:
BOOL SetNamedPipeHandleState( HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout);
这个默认的timeout只是客户端连接的超时时间
@林川: 那就只能临时的使用异步io来等待了,或者:http://stackoverflow.com/questions/1353263/how-to-unblock-connectnamedpipe-and-readfile-c