Put the generic parts from StaticContentsSock
into a separate class ZeroSock
so that they can be reused in other mocked Sock
implementations.
Add a new DynSock
whose Recv()
and Send()
methods can be controlled after the object is created. To achieve that, the caller/creator of DynSock
provides to its constructor two pipes (FIFOs) - recv-pipe and send-pipe. Whatever data is written to recv-pipe is later received by DynSock::Recv()
method and whatever data is written to the socket using DynSock::Send()
can later be found in the send-pipe. For convenience there are also two methods to send and receive CNetMessage
s.
This is used in #26812 (first two commits from that PR). Extracting as a separate PR suggested here: #30043 (review).