Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <thread>
- #include <chrono>
- #include "soapH.h"
- #include "ns1.nsmap"
- #include "httpget.h"
- #define TIME_OUT 90 //very high timeout
- static bool keep_running;
- static struct soap *soapInstance;
- void connection()
- {
- const char * endPoint = "http://example.com/";
- while (keep_running)
- {
- //if this call gets blocked, it is not unblocked by a soap_done call, when it should be
- if (soap_get_connect(soapInstance, endPoint, NULL))
- {
- printf("Error en soap_get_connect: %dn", soapInstance->error);
- return;
- }
- if (soap_begin_recv(soapInstance) != SOAP_OK)
- {
- printf("Error en soap_begin_recv: %dn", soapInstance->error);
- return;
- }
- soap_end_recv(soapInstance);
- std::this_thread::sleep_for(std::chrono::milliseconds(1500));
- }
- }
- int main()
- {
- char input[10];
- memset(input, 0, sizeof input);
- soapInstance = soap_new();
- soapInstance->recv_timeout = TIME_OUT;
- soapInstance->send_timeout = TIME_OUT;
- soapInstance->connect_timeout = TIME_OUT;
- soap_mode(soapInstance, SOAP_XML_IGNORENS | SOAP_C_UTFSTRING);
- soap_register_plugin(soapInstance, ::http_get);
- keep_running = true;
- std::thread runConnectionThread(connection);
- while (strcmp(input, "quit") != 0)
- {
- scanf("%s", input);
- }
- std::cout << "Stopping gsoap connections" << std::endl;
- soap_done(soapInstance);//this should end gsoap connections, but it is not working
- keep_running = false;
- runConnectionThread.join();
- soap_destroy(soapInstance);
- soap_end(soapInstance);
- soap_free(soapInstance);
- return 0;
- }
Add Comment
Please, Sign In to add comment