ThreadedSocketConnection.h
Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /****************************************************************************
00004 ** Copyright (c) 2001-2014
00005 **
00006 ** This file is part of the QuickFIX FIX Engine
00007 **
00008 ** This file may be distributed under the terms of the quickfixengine.org
00009 ** license as defined by quickfixengine.org and appearing in the file
00010 ** LICENSE included in the packaging of this file.
00011 **
00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 **
00015 ** See http://www.quickfixengine.org/LICENSE for licensing information.
00016 **
00017 ** Contact ask@quickfixengine.org if any conditions of this licensing are
00018 ** not clear to you.
00019 **
00020 ****************************************************************************/
00021 
00022 #ifndef FIX_THREADEDSOCKETCONNECTION_H
00023 #define FIX_THREADEDSOCKETCONNECTION_H
00024 
00025 #ifdef _MSC_VER
00026 #pragma warning( disable : 4503 4355 4786 4290 )
00027 #endif
00028 
00029 #include "Parser.h"
00030 #include "Responder.h"
00031 #include "SessionID.h"
00032 #include <set>
00033 #include <map>
00034 
00035 namespace FIX
00036 {
00037 class ThreadedSocketAcceptor;
00038 class ThreadedSocketInitiator;
00039 class Session;
00040 class Application;
00041 class Log;
00042 
00044 class ThreadedSocketConnection : Responder
00045 {
00046 public:
00047   typedef std::set<SessionID> Sessions;
00048 
00049   ThreadedSocketConnection( int s, Sessions sessions, Log* pLog );
00050   ThreadedSocketConnection( const SessionID&, int s, 
00051                             const std::string& address, short port, 
00052                             Log* pLog );
00053   virtual ~ThreadedSocketConnection() ;
00054 
00055   Session* getSession() const { return m_pSession; }
00056   int getSocket() const { return m_socket; }
00057   bool connect();
00058   void disconnect();
00059   bool read();
00060 
00061 private:
00062   bool readMessage( std::string& msg ) throw( SocketRecvFailed );
00063   void processStream();
00064   bool send( const std::string& );
00065   bool setSession( const std::string& msg );
00066 
00067   int m_socket;
00068   char m_buffer[BUFSIZ];
00069 
00070   std::string m_address;
00071   int m_port;
00072 
00073   Log* m_pLog;
00074   Parser m_parser;
00075   Sessions m_sessions;
00076   Session* m_pSession;
00077   bool m_disconnect;
00078   fd_set m_fds;
00079 };
00080 }
00081 
00082 #endif //FIX_THREADEDSOCKETCONNECTION_H

Generated on Mon Sep 15 2014 01:23:55 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001