OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Packet Processing Sample

Attaches a packet-level tracer to the Handler to observe raw multicast packet events as they are received, in addition to the usual service events. Useful for low-level diagnostics of the incoming feed.

Source code

#include "../Common/Defaults.h"
#include "../Common/PacketEventTracer.h"
#include "../Common/ServiceEventTracer.h"
#include "../Common/Utils.h"
#include <cstdlib>
int main(int /*argc*/, char** /*argv*/)
{
try
{
introduceMyself("Packet Processing");
FeedEngineSettings feedEngineSettings;
FeedEngine feedEngine(feedEngineSettings);
HandlerSettings handlerSettings;
// For most of Linux operating systems it would be
// better to define following parameter to be able to
// successfully receive market data from multicast feeds.
handlerSettings.networkInterface = NETWORK_INTERFACE;
// Let's activate logging to get data for support.
handlerSettings.logLevel = LogLevels::Debug;
handlerSettings.logDirectory = LOG_DIRECTORY;
handlerSettings.logFileNamePrefix = LOG_FILE_NAME_PREFIX;
// By default, license is stored in lib folder of the distribute
// package. Instead of copying, let's use original file.
handlerSettings.licenseDirectory = LICENSE_DIRECTORY;
// Primary settings - connectivity configuration.
handlerSettings.connectivityConfiguration = AP1_C10Y_FILE;
// Constructs handler with custom license root and enabled logging.
Handler handler(handlerSettings);
// Binds the handler to the feed engine.
handler.bindFeedEngine(feedEngine);
// Traces all service events coming from handlers.
ServiceEventTracer serviceEventTracer;
serviceEventTracer.attachTo(handler);
// Traces all packet events coming from handler.
PacketEventTracer packetEventTracer;
packetEventTracer.attachTo(handler);
// Making subscription.
MarketSubscriptions subscriptions;
MarketSubscription brentFutures(
);
subscriptions.insert(brentFutures);
// Now starts the subscription.
handler.start(subscriptions);
readUserResponse();
std::cout << "Shutdown the Handler..." << std::endl;
// Stop multicast data processing.
handler.stop();
std::cout << "Done." << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Error: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "Unknown exception." << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}