title: How do I send async data via libwebsocket?
body: <p>I am using warmcat's libwebsocket C library for a small websocket server.  I have the examples up and working and can send data in response to receiving data from the websocket (such as echoing back the reversed bytes sent).  However, I haven't been able to figure out how to send data asynchronously from the server without already being in the libwebsocket callback function.  I need the wsi pointer to pass to libwebsocket_write() but don't see how to get the pointer except while in the callback.</p>
  
  <p>I've read that libwebsocket is not thread safe, as my own experience seems to confirm.</p>
  
  <p>In libwebsockets.c:line2483, I read that "The protocol callback functions are [...] called periodically to allow async transmission."  This is exactly what I want but I haven't observed this happening in my own code and haven't found any way to "turn it on".</p>
  
  <p>Suggestions on how to write asynchronously to the websocket I am serving?</p>
  
  <p>Code for libwebsocket: <a href="http://git.warmcat.com/cgi-bin/cgit/libwebsockets/" rel="noreferrer">http://git.warmcat.com/cgi-bin/cgit/libwebsockets/</a></p>
  
  <p>Example of use: <a href="http://martinsikora.com/libwebsockets-simple-websocket-server" rel="noreferrer">http://martinsikora.com/libwebsockets-simple-websocket-server</a></p>