Well, if it was me starting from scratch, I'd probably have a go at using
POE, which implements user-space threads and can handle most of the typical networking problems. What you're probably looking for can be found in the
Components section.
Good luck :-)