title: Thread listening to UDP problems
body: <p>My program receive some UDP messages, each of them sent with mouse clicks by the client. The program has the main thread (the GUI) only to set some parameters and a second thread create, with </p>
  
  <pre><code>CreateThread(NULL, 0, MyFunc, &amp;Data, 0, &amp;ThreadTd);
  </code></pre>
  
  <p>that is listening to UDP packets. 
  This is MyFunc:</p>
  
  <pre><code>... 
  sd=socket(AF_INET, SOCK_DGRAM, 0);
  if(bind(sd,(struct sockaddr *)&amp;server,sizeof(struct sockaddr_in))==-1)
    ....
  while(true){
  bytes_received=recvfrom(sd,buffer,BUFFER_SIZE,0,(struct sockaddr *)&amp;client,&amp;client_length);
  //parsing of the buffer
  }
  </code></pre>
  
  <p>In order to prove that there is no packet loss, if I've used a simple script that listen UDP messages sent by my client using a certain port, all the packets sent are received by my computer. 
  When I run my application, as soon as the client do the first mouse click, the UDP message is received, but If I try to send other messages (other mouse clicks), the server doesn't receive them (like if he doesn't catch them) and client-side, the user have to click at least 2 times before the server catch the message.
  The main thread isn't busy all the time and the second thread parses only the incoming message, enhancing some variables and I haven't assign any priority to the threads.</p>
  
  <p>Any suggetions? </p>