Make reactor loop actually work.

- Added free functions for socket class.
- Removed read/write functions form socket class.
- Refactor handler code into new module in nocontrol.
- Fix object slicing bug that was causing undefined behavior.