title: Gsoap Error in C++
body: <p>I am using gsoap to create a soap server in C++. Messages are routed through a bus written in Java. Both the server and the bus are multithreaded. Everything works well sending one message at a time through the system. If I start 3 clients each sending messages as fast as possible everything is fine for about 3500 messages. Then I begin receiving periodic "Only one socket connection allowed at a time." errors from the gsoap code. Typical about 3950 of 4000 messages make it through OK. With all 50 failures happening in the last 500 sends. </p>
  
  <ol>
  <li><p>Why would these errors occur after many sends, but not at the beginning of the sending? The rate of send does not increase.</p></li>
  <li><p>What is it talking about? I cannot find any explanation of the error, and its meaning is not clear to me.</p></li>
  <li><p>Anyone successfully multithreaded a gsoap app?</p></li>
  </ol>
  
  <p>Here is my server code.</p>
  
  <pre><code>long WINAPI threadGO(soap *x);
  
  int main(int argc, char* argv[])
  {
  HANDLE thread1;
  int m, s; /* master and slave sockets */
  struct soap *soap = soap_new();
  if (argc &lt; 2)
  soap_serve(soap); /* serve as CGI application */
  else
  { 
    m = soap_bind(soap, NULL, atoi(argv[1]), 100); 
    if (m &lt; 0)
    { 
        soap_print_fault(soap, stderr);
        exit(-1);
    }
    fprintf(stderr, "Socket connection successful: master socket = %d\n", m);
    for (;;)
    {
       s = soap_accept(soap);
       thread1 =    CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)threadGO,soap_copy(soap),0,NULL);
    }
  }
  soap_done(soap);
  free(soap);
  return 0;
  }
  
  long WINAPI threadGO(soap *x)
  {
  soap_serve(x);
  soap_end(x);
  return 0
  
  ;
  }
  </code></pre>