linux - gSOAP Chaining C++ Server Classes to Accept Messages on the Same Port Not Working -


we have 6 wsdls compiled within same project, , due limits of hardware can open 1 port listening.

for doing this, choose approach described chapter 7.2.8 how chain c++ server classes accept messages on same port in gsoap manual.

however, when using approach in encounter many sever issues:

1. if lots of requests arrive concurrently, soap_begin_serve reports error error=-1, socket closed soap server after established

2. if call xxx.destory() after soap_free_stream(), soap_accept() report error of bad file descriptor , not work anymore (solved)

anybody knows reasons of above phoenomenon? how solve them?
our code close example except few changes, see below section.

//server thread  abc::soapabcservice server; // generated soapcpp2 -i -x -n -qabc  server.bind(null, 12345, 100);   server.soap_mode = soap_keep_alive | soap_utf_cstring; server.recv_timeout = server.send_timeout = 60;  while (true) {     server.accept();       ...      pthread_create(&pid, null, handle_new_request, server.copy());  }  // while(true)     // work thread - thread function  void *handle_new_request(void* arg)  {     // generated soapcpp2 -i -x -n -qabc      abc::soapabcservice *abc = (abc::soapabcservice*)arg;      uvw::soapuvwservice uvw; // generated soapcpp2 -i -x -n -quvw      xyz::soapxyzservice xyz; // generated soapcpp2 -i -x -n -qxyz      if(soap_begin_serve(abc))      {         //sometimes reports error         //due unkown reason, socket closed soap server          abc->soap_stream_fault(std::cerr);      }     else if (abc->dispatch() == soap_no_method)      {          soap_copy_stream(&uvw, abc);         uww.state = soap_copy;          if (uvw.dispatch() == soap_no_method)          {              soap_copy_stream(&xyz, &uvw);              xyz.state = soap_copy;              if (xyz.dispatch())              {                  soap_send_fault(&xyz); // send fault client                  xyz.soap_stream_fault(std::cerr);              }               soap_free_stream(&xyz); // free copy              xyz.destroy();         }          else         {              soap_send_fault(&uvw); // send fault client              uvw.soap_stream_fault(std::cerr);          }            soap_free_stream(&uvw); // free copy          uvw.destroy();     }     else if (abc->error)     {         abc->soap_stream_fault(std::cerr);     }     else     {      }      abc->destroy();     delete abc;     abc = null;  }        

finally found reason why connections closed server rightly after established.

it's not gsoap server's fault, it's because connections coming same machine, these clients set reuse address , port reuse caused problem.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -