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  const std::string& sourceAddress = "", short sourcePort = 0);
54  virtual ~ThreadedSocketConnection() ;
55 
56  Session* getSession() const { return m_pSession; }
57  int getSocket() const { return m_socket; }
58  bool connect();
59  void disconnect();
60  bool read();
61 
62 private:
63  bool readMessage( std::string& msg ) throw( SocketRecvFailed );
64  void processStream();
65  bool send( const std::string& );
66  bool setSession( const std::string& msg );
67 
68  int m_socket;
69  char m_buffer[BUFSIZ];
70 
71  std::string m_address;
72  int m_port;
73  std::string m_sourceAddress;
75 
78  Sessions m_sessions;
81  fd_set m_fds;
82 };
83 }
84 
85 #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:278
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 Sun Apr 15 2018 21:44:02 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001