/* * blockingUDPTest.cpp * * Created on: Dec 28, 2010 * Author: Miha Vitorovic */ #include "remote.h" #include "blockingUDP.h" #include "logger.h" #include "hexDump.h" #include #include #include using namespace epics::pvAccess; using std::cout; using std::endl; using std::hex; using std::dec; class ContextImpl : public Context { public: ContextImpl() : _tr(new TransportRegistry()), _timer(new Timer("server thread", lowPriority)), _conf(new SystemConfigurationImpl()) { } virtual ~ContextImpl() { delete _tr; delete _timer; } virtual Timer* getTimer() { return _timer; } virtual TransportRegistry* getTransportRegistry() { return _tr; } virtual Channel* getChannel(epics::pvAccess::pvAccessID) { return 0; } virtual Transport* getSearchTransport() { return 0; } virtual Configuration* getConfiguration() { return _conf; } private: TransportRegistry* _tr; Timer* _timer; Configuration* _conf; }; class DummyResponseHandler : public ResponseHandler { public: DummyResponseHandler(Context* context) : ResponseHandler(context), packets(0) { } int getPackets() { return packets; } virtual void handleResponse(osiSockAddr* responseFrom, Transport* transport, int8 version, int8 command, int payloadSize, ByteBuffer* payloadBuffer); private: int packets; }; void DummyResponseHandler::handleResponse(osiSockAddr* responseFrom, Transport* transport, int8 version, int8 command, int payloadSize, ByteBuffer* payloadBuffer) { std::ostringstream os; cout<<"Received new UDP datagram["<ia, ipAddressStr, sizeof(ipAddressStr)); cout<<"From: "<get(payload, 0, dataCount); os<<"Payload ("<start(); cout<<"Waiting for 10 packets..."<