SocketAcceptor.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_SOCKETACCEPTOR_H
  21. #define FIX_SOCKETACCEPTOR_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include "Acceptor.h"
  26. #include "SocketServer.h"
  27. #include "SocketConnection.h"
  28. namespace FIX
  29. {
  30. /// Socket implementation of Acceptor.
  31. class SocketAcceptor : public Acceptor, SocketServer::Strategy
  32. {
  33. friend class SocketConnection;
  34. public:
  35. SocketAcceptor( Application&, MessageStoreFactory&,
  36. const SessionSettings& ) throw( ConfigError );
  37. SocketAcceptor( Application&, MessageStoreFactory&,
  38. const SessionSettings&, LogFactory& ) throw( ConfigError );
  39. virtual ~SocketAcceptor();
  40. private:
  41. bool readSettings( const SessionSettings& );
  42. typedef std::set < SessionID > Sessions;
  43. typedef std::map < int, Sessions > PortToSessions;
  44. typedef std::map < int, SocketConnection* > SocketConnections;
  45. void onConfigure( const SessionSettings& ) throw ( ConfigError );
  46. void onInitialize( const SessionSettings& ) throw ( RuntimeError );
  47. void onStart();
  48. bool onPoll( double timeout );
  49. void onStop();
  50. void onConnect( SocketServer&, int, int );
  51. void onWrite( SocketServer&, int );
  52. bool onData( SocketServer&, int );
  53. void onDisconnect( SocketServer&, int );
  54. void onError( SocketServer& );
  55. void onTimeout( SocketServer& );
  56. SocketServer* m_pServer;
  57. PortToSessions m_portToSessions;
  58. SocketConnections m_connections;
  59. };
  60. /*! @} */
  61. }
  62. #endif //FIX_SOCKETACCEPTOR_H