我想使用带管道的异步RPC将数据推送到服务器。这是我的代码:
//file: Xasyncpipe.idl:
interface IMyAsyncPipe
{
//define the pipe type
typedef pipe int ASYNC_INTPIPE;
int MyAsyncInputPipe(
handle_t hBinding,
[in] ASYNC_INTPIPE *inpipe) ;
};
//file:Xasyncpipe.acf:
interface IMyAsyncPipe
{
[async] MyAsyncInputPipe () ;
} ;
//file:Client.cpp
mian()
{
// Creates a binding handle.
...
RPC_ASYNC_STATE Async;
status = RpcAsyncInitializeHandle(&Async, sizeof(RPC_ASYNC_STATE));
Async.UserInfo = NULL;
Async.NotificationType = RpcNotificationTypeIoc;
Async.u.IOC.hIOPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
ASYNC_INTPIPE inputPipe;
// Calls the RPC function.
MyAsyncInputPipe(&Async, hBinding, &inputPipe);
}
//file:Server.cpp
void MyAsyncInputPipe(PRPC_ASYNC_STATE state, handle_t hBinding, ASYNC_INTPIPE *pipe)
{
std::cout << "Input Test" << std::endl;
}
我在函数MyAsyncInputPipe中添加了断点,并且永远不会触发断点。
我将Xasyncpipe.idl从[in] ASYNC_INTPIPE *inpipe
更改为[out] ASYNC_INTPIPE *inpipe
,触发了断点。
有谁知道原因?
答案 0 :(得分:0)
在客户端管道推送终端信号之前,服务器不会接收数据。
//push terminal signal
inputPipe.push(inputPipe.state, NULL, 0);