ThreadedSocketConnection.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_THREADEDSOCKETCONNECTION_H
23 #define FIX_THREADEDSOCKETCONNECTION_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include "Parser.h"
30 #include "Responder.h"
31 #include "SessionID.h"
32 #include <set>
33 #include <map>
34 
35 namespace FIX
36 {
37 class ThreadedSocketAcceptor;
38 class ThreadedSocketInitiator;
39 class Session;
40 class Application;
41 class Log;
42 
45 {
46 public:
47  typedef std::set<SessionID> Sessions;
48 
49  ThreadedSocketConnection( int s, Sessions sessions, Log* pLog );
50  ThreadedSocketConnection( const SessionID&, int s,
51  const std::string& address, short port,
52  Log* pLog );
53  virtual ~ThreadedSocketConnection() ;
54 
55  Session* getSession() const { return m_pSession; }
56  int getSocket() const { return m_socket; }
57  bool connect();
58  void disconnect();
59  bool read();
60 
61 private:
62  bool readMessage( std::string& msg ) throw( SocketRecvFailed );
63  void processStream();
64  bool send( const std::string& );
65  bool setSession( const std::string& msg );
66 
67  int m_socket;
68  char m_buffer[BUFSIZ];
69 
70  std::string m_address;
71  int m_port;
72 
75  Sessions m_sessions;
78  fd_set m_fds;
79 };
80 }
81 
82 #endif //FIX_THREADEDSOCKETCONNECTION_H
Maintains the state and implements the logic of a FIX session.
Definition: Session.h:45
Interface implements sending on and disconnecting a transport.
Definition: Responder.h:34
Encapsulates a socket file descriptor (multi-threaded).
ThreadedSocketConnection(int s, Sessions sessions, Log *pLog)
This interface must be implemented to log messages and events.
Definition: Log.h:81
Definition: Acceptor.cpp:34
Socket recv operation failed.
Definition: Exceptions.h:280
Parses FIX messages off an input stream.
Definition: Parser.h:36
bool setSession(const std::string &msg)
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:30

Generated on Thu Sep 5 2019 11:07:58 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001