00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIX_SOCKETCONNECTOR_H
00023 #define FIX_SOCKETCONNECTOR_H
00024
00025 #ifdef _MSC_VER
00026 #pragma warning( disable : 4503 4355 4786 4290 )
00027 #endif
00028
00029 #include "SocketMonitor.h"
00030 #include <string>
00031
00032 namespace FIX
00033 {
00035 class SocketConnector
00036 {
00037 public:
00038 class Strategy;
00039
00040 SocketConnector( int timeout = 0 );
00041
00042 int connect( const std::string& address, int port, bool noDelay );
00043 int connect( const std::string& address, int port, bool noDelay, Strategy& );
00044 void block( Strategy& strategy, bool poll = 0 );
00045 SocketMonitor& getMonitor() { return m_monitor; }
00046
00047 private:
00048 SocketMonitor m_monitor;
00049
00050 public:
00051 class Strategy
00052 {
00053 public:
00054 virtual ~Strategy() {}
00055 virtual void onConnect( SocketConnector&, int socket ) = 0;
00056 virtual void onWrite( SocketConnector&, int socket ) = 0;
00057 virtual void onData( SocketConnector&, int socket ) = 0;
00058 virtual void onDisconnect( SocketConnector&, int socket ) = 0;
00059 virtual void onError( SocketConnector& ) = 0;
00060 virtual void onTimeout( SocketConnector& ) {};
00061 };
00062 };
00063 }
00064
00065 #endif //FIX_SOCKETCONNECTOR_H