title: Cant I spawn a new thread to handle a new UDP "connection"?
body: <p>I know UDP is connection-less, but could I spawn a new thread to handle new UDP clients that connect to my server?</p>
  
  <p>I'm trying to do this basically:</p>
  
  <pre><code>void *handle_connection(void *param)
  {
      // read data
      ret = recvfrom(..,0,..);
  }
  
  
  // Wait for connection using MSG_PEEK
  ret = recvfrom(.., MSG_PEEK,..);
  
  // New thread to handle client connection
  pthread_t conn_thread;
  ret = pthread_create(..., handle_connection);
  </code></pre>
  
  <p>Is there a way to stablish a UDP "connection" for each client and fork off a new thread to handle it like it's done by OpenSSL when using DTLS?</p>
  
  <p>With OpenSSL I can use DTLS_listen() to wait for a UDP client to connect and then start a new thread, pass the UDP socket to that thread and use usual read/write operations. For that to work though, you have to do a couple of extra bind() and connect() calls on the udp sockets.</p>
  
  <p>I tried the same approach here and just ended up opening a new thread for each datagram received from the client on the server.</p>