实验一 远程过程调用中间件及数据访问中间件

https://blog.csdn.net/u011402642/article/details/46317827?utm_source=blogxgwz9
https://1024tools.com/uuid

错误处理

mathservice.idl

[
 uuid("ff07ca57-6f46-40ab-91c6-3257c199daf7"), // genurate by GUIDGen.exe
 version(1.0)
]
 
interface Compute  
{
    void Shutdown(void);
	float add(float a, float b);
	float substract(float a, float b);
	float logg(float a);
}

mathservic.acf

[  
      implicit_handle(handle_t  Compute_Binding)  
]  

 
interface Compute
{

}

server.c

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

void Shutdown(void)
{
     RpcMgmtStopServerListening(NULL);
     RpcServerUnregisterIf(NULL, NULL, FALSE);
}

float substract(float a, float b)
{
	return a-b;
}

float logg(float a)
{
	return log(a);
}

float add(float a, float b)
{
	return a+b;
}

int main(int argc,char * argv[])
{
     RpcServerUseProtseqEp((unsigned char *)"ncacn_np", 20, (unsigned char *)"\\pipe\\{8dd50205-3108-498f-96e8-dbc4ec074cf9}", NULL);
     RpcServerRegisterIf(Compute_v1_0_s_ifspec, NULL, NULL);
     RpcServerListen(1,20,FALSE);
     return 0;
}


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);
}

运行命令

cl /D_WINNE=0x500 server.c MathServer_s.c
posted @ 2019-03-25 21:03  pprp  阅读(968)  评论(0)    收藏  举报