gsoap 服务端和客户端实现简单的握手
来源:互联网 发布:八大山人 知乎 编辑:程序博客网 时间:2024/05/17 01:09
linux下用C++实现gsoap服务端和客户端实现简单通,本代码是在gsoap-2.8版本下进行。
client.cpp
#include<iostream>
#include "soapH.h"
//#include"soapStub.h"
#include"soapAAAServiceSoapBindingProxy.h"
#include "AAAServiceSoapBinding.nsmap"
using namespace std;
int main(int argc, char **argv) {
/* if ( argc != 2 ) {
printf("Usage: %s stock_code/n", argv[0]);
exit(-1);
} */
char* server="http://localhost:8080";
int result;
struct soap client_soap;
soap_init(&client_soap);
string response;
result=soap_call_ns1__authentication(&client_soap,server,NULL,"hello~~~",response);
if(result ==SOAP_OK)
cout<<response<<endl;
else
soap_print_fault(&client_soap,stderr);
soap_destroy(&client_soap);
soap_end(&client_soap);
soap_done(&client_soap);
return 0;
}
server.cpp
#include"soapH.h"
#include"AAAServiceSoapBinding.nsmap"
#include "soapAAAServiceSoapBindingObject.h"
using namespace std;
int ns1__authentication(struct soap*, std::string _in0, std::string &_authenticationReturn);
int main(int argc,char **argv)
{
int m,s;
struct soap add_soap;
soap_init(&add_soap);
soap_set_namespaces(&add_soap,namespaces);
if(argc<2){
printf("usage:%s <server_port> /n",argv[0]);
exit(1);
}else{
m=soap_bind(&add_soap,NULL,atoi(argv[1]),100);
if(m<0){
soap_print_fault(&add_soap,stderr);
exit(-1);
}
printf("Socket connection successful:master socket = %d/n",m);
for(;;){
s=soap_accept(&add_soap);
if(s<0){
soap_print_fault(&add_soap,stderr);
exit(-1);
}
printf("Socket connection successful:slave socket=%d/n",s);
soap_serve(&add_soap);
soap_end(&add_soap);
}
}
return 0;
}
int ns1__authentication(struct soap*, std::string _in0, std::string &_authenticationReturn)
{
cout<<_in0<<endl;
_authenticationReturn="succeed!";
return 0;
}
- gsoap 服务端和客户端实现简单的握手
- gsoap-Linux服务端,window客户端实现
- 网络编程--python实现 简单的服务端和客户端
- 网络编程--python 实现简单的UDP客户端和服务端
- android客户端和servlet服务端的简单登录实现
- Socket实现客户端和服务端 简单的入门实例
- Java简单实现UDP服务端和客户端的通信
- Socket TCP 协议实现服务端和客户端的简单通信
- nodejs socket实现的服务端和客户端简单通信
- python Socket之客户端和服务端握手
- 简单服务端和客户端的开发
- 简单的Socket通信客户端和服务端
- 客户端和服务端通信的简单小案列
- gSoap开发Web Service 既soapcpp2.exe生成服务端和客户端的代码具体方法
- 简单的Android服务端和客户端登录交互(服务端)
- gSoap开发客户端与服务端
- gsoap客户端服务端对应关系
- 关于Gsoap的简单客户端使用【GSoap的HelloWorld】
- 使用ifconfig临时配置网络
- java 向文档末尾添加内容,打印LOG
- 【linux c开发】time时间处理实例
- alertDialog的自定义style和使用(Android)
- QTcpSocket通信编程时阻塞与非阻塞的问题
- gsoap 服务端和客户端实现简单的握手
- 网络驱动器映射
- 【linux c开发】pthread处理实例
- MongoDB笔记
- 压缩表
- Android 内存溢出解决方案(OOM) 整理总结
- frame和iframe的具体区别
- 一些Linux常用命令
- 前端CSS规范整理