title: Event Handling for Networking in C++
body: <p>I've currently coded a server/client implementation in C++, where two clients connect to a server. I'm expecting from previous experience (I'm new to C++) that each client (and the server) will have an event handler, and events will come in when either the client wants to send a message to the server, or the client has received a message from the server. You can view it as a chat server; the 'outgoing' event from the client could be the triggered by the user typing something in the console, and the 'incoming' event could be triggered by receiving data from the server.</p>
  
  <p>Is there a standard way of coding this in C++? I'd ideally like to register callback functions for each possible event type, and for the callback function registered to be passed back as a context to the event handler when each event is received, so I can process each event in its specific handling function. And of course once the event has been handled, I want my program to fall back into its event loop.</p>
  
  <p>Any ideas? I'm very comfortable with the event-driven style of programming so would prefer to keep it this way if possible rather than learning entirely new paradigms.</p>