SocketInitiator.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_SOCKETINITIATOR_H
  21. #define FIX_SOCKETINITIATOR_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include "Initiator.h"
  26. #include "SocketConnector.h"
  27. #include "SocketConnection.h"
  28. namespace FIX
  29. {
  30. /// Socket implementation of Initiator.
  31. class SocketInitiator : public Initiator, SocketConnector::Strategy
  32. {
  33. public:
  34. SocketInitiator( Application&, MessageStoreFactory&,
  35. const SessionSettings& ) throw( ConfigError );
  36. SocketInitiator( Application&, MessageStoreFactory&,
  37. const SessionSettings&, LogFactory& ) throw( ConfigError );
  38. virtual ~SocketInitiator();
  39. private:
  40. typedef std::map < int, SocketConnection* > SocketConnections;
  41. typedef std::map < SessionID, int > SessionToHostNum;
  42. void onConfigure( const SessionSettings& ) throw ( ConfigError );
  43. void onInitialize( const SessionSettings& ) throw ( RuntimeError );
  44. void onStart();
  45. bool onPoll( double timeout );
  46. void onStop();
  47. void doConnect( const SessionID&, const Dictionary& d );
  48. void onConnect( SocketConnector&, int );
  49. void onWrite( SocketConnector&, int );
  50. bool onData( SocketConnector&, int );
  51. void onDisconnect( SocketConnector&, int );
  52. void onError( SocketConnector& );
  53. void onTimeout( SocketConnector& );
  54. void getHost( const SessionID&, const Dictionary&, std::string&, short& );
  55. SessionSettings m_settings;
  56. SessionToHostNum m_sessionToHostNum;
  57. SocketConnector m_connector;
  58. SocketConnections m_pendingConnections;
  59. SocketConnections m_connections;
  60. time_t m_lastConnect;
  61. int m_reconnectInterval;
  62. bool m_noDelay;
  63. int m_sendBufSize;
  64. int m_rcvBufSize;
  65. };
  66. /*! @} */
  67. }
  68. #endif //FIX_SOCKETINITIATOR_H