rpctestsrvr.c
来自「VC++高级编程技巧与示例」· C语言 代码 · 共 88 行
C
88 行
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "RPCTest.h"
#include "math.h"
double Calculate(double val)
{
double re;
printf("The input value from client is:%f\n",val);
re=sin(val);
printf("The result of client request is: %f\n",re);
printf("****************************************\n");
printf("** End of calculation! **\n");
printf("****************************************\n");
return re;
}
void Getout(void)
{
RPC_STATUS status;
printf("Calling RpcMgmtStopServerListening\n");
status = RpcMgmtStopServerListening(NULL);
printf("RpcMgmtStopServerListening returned: 0x%x\n", status);
if (status) {
exit(status);
}
printf("Calling RpcServerUnregisterIf\n");
status = RpcServerUnregisterIf(NULL, NULL, FALSE);
printf("RpcServerUnregisterIf returned 0x%x\n", status);
if (status)
{
exit(status);
}
}
void main()
{
RPC_STATUS status;
unsigned char * pszProtocolSequence = "ncacn_np";
unsigned char * pszSecurity = NULL;
unsigned char * pszEndpoint = "\\pipe\\RPCTest";
unsigned int cMinCalls = 1;
unsigned int cMaxCalls = 20;
unsigned int fDontWait = FALSE;
status = RpcServerUseProtseqEp(pszProtocolSequence,
cMaxCalls,
pszEndpoint,
pszSecurity);
if (status)
{
exit(status);
}
status = RpcServerRegisterIf(RPCTest_v1_0_s_ifspec,
NULL,
NULL);
if (status)
{
exit(status);
}
status = RpcServerListen(cMinCalls,
cMaxCalls,
fDontWait);
if (status)
{
exit(status);
}
} // end main()
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
{
return(malloc(len));
}
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
free(ptr);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?