gSOAP C 編寫伺服器端

2021-08-28 05:22:30 字數 2469 閱讀 9036

**

1.編寫標頭檔案cal.h:

//gsoap ns service name: calc

//gsoap ns service style: rpc

//gsoap ns service encoding: encoded

//gsoap ns service namespace:

//gsoap ns service location:

//gsoap ns schema namespace: urn:calc

int ns__add(double a, double b, double *result);

int ns__sub(double a, double b, double *result);

int ns__mul(double a, double b, double *result);

int ns__div(double a, double b, double *result);

int ns__pow(double a, double b, double *result);

2.生成檔案:

soapcpp2.exe -i cal.h
3.將以下檔案拷入專案:

4.編寫gsoapservice.cpp:

\#define _crt_secure_no_warnings   **//一定要新增上**

\#include "calc.nsmap"

\#include"soapcalcservice.h"

\#include "iostream" //控制項問提只能寫「」

using namespace std;

//很重要

}//自動生成了calcservice類,自己重寫add等函式

/*加法的具體實現*/

int calcservice::add(double num1, double num2, double* result)

else

return soap_ok;

}/*減法的具體實現*/

int calcservice::sub(double num1, double num2, double* result)

else

return soap_ok;

}/*乘法的具體實現*/

int calcservice::mul(double num1, double num2, double* result)

else

return soap_ok;

}/*除法的具體實現*/

int calcservice::div(double num1, double num2, double* result)

else

return soap_ok;

}int calcservice::pow(double num1, double num2, double* result)

else

return soap_ok;

}

測試一:

測試二:

執行伺服器程式,並執行:

stdsoap2在gsoap目錄中搜尋。 

test.cpp:

\#include"soapcalcproxy.h"

\#include"calc.nsmap"

\#include"iostream"

using namespace std;

int main()

else

system("pause");

return 0;

}

socket伺服器端

伺服器 include winsock2.h include string.h include stdio.h include time.h include stdarg.h include stdlib.h pragma comment lib,ws2 32 void errexit const ...

kerberos伺服器端

1.安裝tcl wget tar zvxf tcl8.5.12 src.tar.gz cd tcl8.5.12 cd unix configure make make install 3.解壓 tar xvf krb5 1.10.3 signed.tar tar zvxf krb5 1.10.3.t...

C tcp伺服器端

伺服器端 include stdafx.h include winsock2.h pragma comment lib,ws2 32.lib include using namespace std int tmain int argc,char ar 建立套接字 sserver socket af ...