Files CCore/inc/net/SingleBridge.h CCore/src/net/SingleBridge.cpp
This class is similar to the Bridge, but implements point-to-point communication.
class SingleBridge : NoCopy
{
....
public:
SingleBridge();
SingleBridge(PacketFormat to_server_format,PacketFormat to_client_format);
~SingleBridge();
// methods
void setDropRate(uint32 drop_rate,uint32 drop_den);
static StrLen ServerName();
static StrLen ClientName();
// start/stop
friend class StartStopObject<SingleBridge>;
using StartStop = StartStopObject<SingleBridge> ;
};
Once a SingleBridge object is created, it creates and registers a server device and a client device. The server device has the name ServerName(). The client device has the name ClientName(). Both server and client implement the PacketEndpointDevice interface and the PortManager co-interface. The port numbering is trivial: all addresses ports are zero. So you can attach to these devices another protocol devices.
The second constructor allows you to specify packet formats to and from server. You may also set the packet drop rate to simulate the packet loss. Use the method setDropRate(). The drop probability is drop_rate/drop_den.
To drive the SingleBridge, you have to start it using the inner class StartStop.