Implement Register / Cancel for sockets. #189

Sockets can now be registered and cancelled from the socket manager.
Fix generic_stats.h so it can be included by itself. #189