Callbacks for regular socket programming

I was trying to figure out how to use the InterprocessConnection classes to build a simple server and only just figured out that MessageReceived wasn't being triggered from my simple telnet client because I wasn't using magic numbers


It seems to me that it would be extremely useful to have one of

a) A version of StreamingSocket that has a general MessageReceived callback --- main benefit is to get the automatic thread management. I know blocking is normally appropriate but it's very handy sometimes for simple stuff to just have a callback

b) Probably better --- a virtual readNextMessage in InterprocessConnection that would by default just call readNextMessageInt for compatibility but could be changed so that it just called MessageReceived with the raw received data.


For now I'm just going to change the InterprocessConnection::runThread so that it will do something like this in my own code



That's not really functionality that would belong in the socket class itself - you'd implement it as a separate class that uses a StreamingSocket, but you can certainly write such a class yourself.