Implement network_stream class
The current network code duplicates the handling of recv/send stuff. Create a unique network_stream class which automatically handle recv/send stuff and flushing.
Common: implement network_stream class, closes #755 @1h
This class handles receive/send operations under the hood, it automatically does
the following things:
- parse/dump JSON message using '\r\n\r\n',
- detect errors/disconnections and mark them as network_down,
- flush receive/send after a successful operation.
Acked-by: Alexis Dörr