SocketConnector.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /****************************************************************************
4 ** Copyright (c) 2001-2014
5 **
6 ** This file is part of the QuickFIX FIX Engine
7 **
8 ** This file may be distributed under the terms of the quickfixengine.org
9 ** license as defined by quickfixengine.org and appearing in the file
10 ** LICENSE included in the packaging of this file.
11 **
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 **
15 ** See http://www.quickfixengine.org/LICENSE for licensing information.
16 **
17 ** Contact ask@quickfixengine.org if any conditions of this licensing are
18 ** not clear to you.
19 **
20 ****************************************************************************/
21 
22 #ifndef FIX_SOCKETCONNECTOR_H
23 #define FIX_SOCKETCONNECTOR_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include "SocketMonitor.h"
30 #include <string>
31 
32 namespace FIX
33 {
35 class SocketConnector
36 {
37 public:
38  class Strategy;
39 
40  SocketConnector( int timeout = 0 );
41 
42  int connect( const std::string& address, int port, bool noDelay,
43  int sendBufSize, int rcvBufSize,
44  const std::string& sourceAddress = "", int sourcePort = 0);
45  int connect( const std::string& address, int port, bool noDelay,
46  int sendBufSize, int rcvBufSize, Strategy& );
47  void block( Strategy& strategy, bool poll = 0, double timeout = 0.0 );
48  SocketMonitor& getMonitor() { return m_monitor; }
49 
50 private:
51  SocketMonitor m_monitor;
52 
53 public:
54  class Strategy
55  {
56  public:
57  virtual ~Strategy() {}
58  virtual void onConnect( SocketConnector&, int socket ) = 0;
59  virtual void onWrite( SocketConnector&, int socket ) = 0;
60  virtual bool onData( SocketConnector&, int socket ) = 0;
61  virtual void onDisconnect( SocketConnector&, int socket ) = 0;
62  virtual void onError( SocketConnector& ) = 0;
63  virtual void onTimeout( SocketConnector& ) {};
64  };
65 };
66 }
67 
68 #endif //FIX_SOCKETCONNECTOR_H
FIX::SocketConnector::Strategy::onDisconnect
virtual void onDisconnect(SocketConnector &, int socket)=0
FIX::SocketConnector::Strategy::onTimeout
virtual void onTimeout(SocketConnector &)
Definition: SocketConnector.h:97
FIX::SocketConnector::Strategy
Definition: SocketConnector.h:88
FIX::SocketConnector::Strategy::~Strategy
virtual ~Strategy()
Definition: SocketConnector.h:91
FIX::SocketConnector
Connects sockets to remote ports and addresses.
Definition: SocketConnector.h:52
FIX::SocketConnector::Strategy::onWrite
virtual void onWrite(SocketConnector &, int socket)=0
FIX::SocketConnector::Strategy::onError
virtual void onError(SocketConnector &)=0
FIX::SocketConnector::SocketConnector
SocketConnector(int timeout=0)
Definition: SocketConnector.cpp:99
SocketMonitor.h
FIX::SocketConnector::connect
int connect(const std::string &address, int port, bool noDelay, int sendBufSize, int rcvBufSize, const std::string &sourceAddress="", int sourcePort=0)
Definition: SocketConnector.cpp:102
FIX::SocketConnector::m_monitor
SocketMonitor m_monitor
Definition: SocketConnector.h:85
FIX::SocketConnector::Strategy::onData
virtual bool onData(SocketConnector &, int socket)=0
FIX
Definition: Acceptor.cpp:34
FIX::SocketConnector::getMonitor
SocketMonitor & getMonitor()
Definition: SocketConnector.h:82
FIX::SocketConnector::Strategy::onConnect
virtual void onConnect(SocketConnector &, int socket)=0
FIX::SocketConnector::block
void block(Strategy &strategy, bool poll=0, double timeout=0.0)
Definition: SocketConnector.cpp:131

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001