To establish the a FIX connection as an Acceptor the OnixS::FIX::Session::logonAsAcceptor method must be used.
To establish the a FIX connection as an Initiator the OnixS::FIX::Session::logonAsInitiator method must be used.
To disconnect the session OnixS::FIX::Session::logout method must be used. This member implements a graceful closing of the FIX connection as defined by the Standard.
A single FIX session can exist across multiple sequential (not concurrent) physical connections. Parties can connect and disconnect multiple times while maintaining a single FIX session. That is, once the OnixS::FIX::Session::logout method is called, the FIX Connection is terminated however the FIX session life continues. It is possible to continue the same session later using either OnixS::FIX::Session::logonAsAcceptor or OnixS::FIX::Session::logonAsInitiator methods again. In other words, a FIX Session is comprised of one or more FIX connections.
#include <OnixS/FIXEngine.h> using namespace OnixS::FIX; using namespace OnixS::FIX::FIX40; const string SENDER_COMP_ID = "SenderCompID"; const string TARGET_COMP_ID = "TargetCompID"; const Version VERSION = FIX_40; const string HOST = "Localhost"; // Target port is equal to acceptor's port to create a loop back FIX session. int ACCEPTOR_PORT = Engine::instance()->getListenPort(); ISessionListener listener; Session acceptor(TARGET_COMP_ID, SENDER_COMP_ID, VERSION, &listener); Session initiator(SENDER_COMP_ID, TARGET_COMP_ID, VERSION, &listener); acceptor.logonAsAcceptor(); // Sends the Logon message and waits for the acknowledgment Logon. initiator.logonAsInitiator(HOST, ACCEPTOR_PORT); // Message exchange and processing logic goes here.. // Sends the Logout message and waits for the confirming Logout. acceptor.logout(); initiator.logout(); // Frees allocated resources. initiator.shutdown(); acceptor.shutdown();