本文介绍了ConnectNamedPipe不响应客户端的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我调用CreateNamedPipe来指定重叠模式,然后创建一个事件并将其放入OVERLAPPED结构中.然后,我分叉到另一个线程,在那儿我调用ConnectNamedPipe并等待使用WaitForSingleObject的连接事件.它阻塞了一个线程 但是在另一个进程中调用CreateFile后,它不会返回线程.
I call CreateNamedPipe specifying an overlapped mode, then I create an event and put it into OVERLAPPED structure. Then I fork to another thread and there I call ConnectNamedPipe and wait for a connection event using WaitForSingleObject. It blocks a thread but it does not return to thread after I call CreateFile at another process.
服务器代码:
OVERLAPPED ovlGlobal;
HANDLE hPipeGlobal;
unsigned
long
int
__stdcall ConnectNamedPipeThreadProc(void
*parameter){
ovlGlobal.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
ConnectNamedPipe(hPipeGlobal,&ovlGlobal);
WaitForSingleObject(ovlGlobal.hEvent,INFINITE);
/* here is a call to ReadFileEx */
}
void
CreateButtonClick(){
wchar_t
pipepath[600]=L"\\\\.\\pipe\\123123"
;
hPipeGlobal = CreateNamedPipe(pipepath,
PIPE_ACCESS_DUPLEX|FILE_FLAG_FIRST_PIPE_INSTANCE|FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE|PIPE_NOWAIT,
PIPE_UNLIMITED_INSTANCES,
64*1024,
64*1024,
60*1000,
NULL);
CreateThread(NULL,0,ConnectNamedPipeThreadProc,NULL,0,NULL);
}
推荐答案
感谢您的提问.这是IPC产品小组的话:
Thanks for the question. Here's the word from the IPC product team:
观察到的行为与文档一致:
这篇关于ConnectNamedPipe不响应客户端的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!