网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

onvifserverDiscovery实现

#include "soapH.h"  

创新互联是专业的茅箭网站建设公司,茅箭接单;提供网站建设、做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行茅箭网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

#include "wsddapi.h"

#include

#include          /* See NOTES */

#include

#include

#include

extern int GetListenPort();

void* main_probe(void* arg)

{

    int m, s;

    struct ip_mreq mcast;

    struct soap soap;

    soap_init2(&soap, SOAP_IO_UDP | SOAP_IO_FLUSH, SOAP_IO_UDP|SOAP_IO_FLUSH);  

    soap_set_namespaces(&soap, namespaces);

    soap_set_mode(&soap, SOAP_C_UTFSTRING);//客户端接收支持中文 

    soap.bind_flags        = SO_REUSEADDR;

    soap.connect_timeout   = 10;

    soap.recv_timeout      = 5;

    soap.send_timeout      = 5;

    soap_register_plugin(&soap, soap_wsa);

 // 打开调试信息,需 1)、首先gsoap安装时,在./configure --prefix=/usr/local/gsoap --enable-debug

  // 2)、在/usr/local/gsoap/include/sdtsoap2.h文件中开启#define DEBUG

    //soap_set_recv_logfile(&soap, "./log/recv.xml");

    //soap_set_sent_logfile(&soap, "./log/send.xml");

    //soap_set_test_logfile(&soap, "./log/test.log");

    if(!soap_valid_socket(soap_bind(&soap, NULL, 3702, 16)))

    {

soap_print_fault(&soap, stderr);

exit(1);

    }

    mcast.imr_multiaddr.s_addr = inet_addr("239.255.255.250");

    mcast.imr_interface.s_addr = inet_addr("0.0.0.0");

    if(setsockopt(soap.master, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&mcast, sizeof(mcast)) < 0) 

    {

        printf("setsockopt error!\n");

        return 0;

    }  

    //成功绑定之后,便开始监听

    for (;;) {

        //监听直到有连接请求

        soap_wsdd_listen(&soap, 0);

        soap_destroy(&soap);

        soap_end(&soap);

        fprintf(stderr, "Socket connection successful: slave socket = %d\n", s);

    }

    soap_done(&soap);

    return (void*)0;

}

int   http_get(struct  soap   *soap) 

/*

The callback is required to produce a response to the request in textual form, such as a

Web page or a SOAP/XML response. This method does not work with CGI.

*/

{

soap->http_content = "text/xml";  //HTTP header with text /xml content

char szContent[100] = {0};

sprintf(szContent, "welcome to use webservice!");

sprintf(soap->tmpbuf, szContent);

soap_send_raw(soap, soap->tmpbuf, strlen(szContent));

}

soap_end_send(soap);

return SOAP_OK; 

}

int main(int argc, char **argv)    

{   

int m, s;    

    struct soap thesoap;    

  

    pthread_t thrProbe;  

 

    pthread_create(&thrProbe,NULL,main_probe,NULL);  

  

    soap_init(&thesoap);    

    soap_set_namespaces(&thesoap, namespaces);

#ifdef DEBUG

printf("debug mode\n");

#else 

printf("release mode\n");

#endif

thesoap.fget = http_get;

  

  

    if (argc < 0) {    

        printf("usage: %s \n", argv[0]);    

        exit(1);    

    } else { 

  // LOAD_CFGFILE(root);

   int port = GetListenPort();//8085;//root["port"].asInt();

   m = soap_bind(&thesoap, NULL, port, 100);    

        if (m < 0) {    

            soap_print_fault(&thesoap, stderr);    

            exit(-1);    

        }    

        fprintf(stderr, "Socket connection successful: master socket = %d\n", m);    

        for (;;) {    

            s = soap_accept(&thesoap);    

            if (s < 0) {    

                soap_print_fault(&thesoap, stderr);    

                exit(-1);    

            }    

          //  fprintf(stderr, "Socket connection successful: slave socket = %d\n", s);    

            soap_serve(&thesoap);    

            soap_end(&thesoap);

    

      // fprintf(stderr, " soap_end socket = %d\n", s);   

        }    

    }    

    return 0;    

}   


网页名称:onvifserverDiscovery实现
转载来于:http://bjjierui.cn/article/jdcspc.html

其他资讯