OnixS C++ FIX Engine  4.2.0
API Documentation
Exchanging Messages

Sending Messages to a Counterparty

To send a message to a counterparty, the OnixS::FIX::Session::send method must be used. This method is asynchronous. As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected (please see the Resending Messages page).

Receiving Messages from Counterparty

To receive incoming application-level messages, it is necessary to override the OnixS::FIX::ISessionListener::onInboundApplicationMsg method of OnixS::FIX::ISessionListener Class and pass instance of the descendant class to the OnixS::FIX::Session's constructor.


using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX42;
class SessionListener : public ISessionListener
virtual void onInboundApplicationMsg(Message & message, Session *)
// Processing incoming application-level message..
<< "Incoming application-level message: "
<< message.toString()
<< std::endl;
const string SENDER_COMP_ID = "AcceptorAndInitiator_SND";
const string TARGET_COMP_ID = "AcceptorAndInitiator_TRG";
const string ACCEPTOR_HOST = "localhost";
int ACCEPTOR_PORT = Engine::instance()->listenPort();
SessionListener listener;
Session acceptor(SENDER_COMP_ID, TARGET_COMP_ID, version, &listener);
Session initiator(TARGET_COMP_ID, SENDER_COMP_ID, version, &listener);
initiator.logonAsInitiator(ACCEPTOR_HOST, ACCEPTOR_PORT);
Message order(Values::MsgType::Order_Single, version);
order.set(Tags::ClOrdID, "20080808-0955789");
order.set(Tags::HandlInst, Values::HandlInst::Automated_execution_order_private_no_Broker_intervention);
order.set(Tags::Symbol, "MSFT");
order.set(Tags::OrderQty, 100000);
order.set(Tags::Side, Values::Side::Buy);
order.set(Tags::OrdType, Values::OrdType::Market);
order.set(Tags::TransactTime, "20051012-22:10:11");
// Continues the message exchange..
// Done with messaging.