Rewritten the I/O loop. All socket operations are now safe, meaning that
you can delete the socket from anywhere in the hooks and nothing should break. Also, the receive/transmit buffers are now regular xmalloc()'ed buffers, not separate resources which would need shuffling around between pools. sk_close() is gone, use rfree() instead.
Showing with 89 additions and 66 deletions