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 
44 class ThreadedSocketConnection : Responder
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 
76  Log* m_pLog;
80  bool m_disconnect;
81  fd_set m_fds;
82 };
83 }
84 
85 #endif //FIX_THREADEDSOCKETCONNECTION_H
SessionID.h
FIX::ThreadedSocketConnection::readMessage
bool readMessage(std::string &msg)
Definition: ThreadedSocketConnection.cpp:162
FIX::ThreadedSocketConnection::setSession
bool setSession(const std::string &msg)
Definition: ThreadedSocketConnection.cpp:198
FIX::ThreadedSocketConnection::send
bool send(const std::string &)
Definition: ThreadedSocketConnection.cpp:86
FIX::ThreadedSocketConnection::m_port
int m_port
Definition: ThreadedSocketConnection.h:89
FIX::ThreadedSocketConnection::getSocket
int getSocket() const
Definition: ThreadedSocketConnection.h:74
FIX::ThreadedSocketConnection::processStream
void processStream()
Definition: ThreadedSocketConnection.cpp:173
FIX::ThreadedSocketConnection::disconnect
void disconnect()
Definition: ThreadedSocketConnection.cpp:108
FIX::ThreadedSocketConnection::Sessions
std::set< SessionID > Sessions
Definition: ThreadedSocketConnection.h:64
FIX::ThreadedSocketConnection::getSession
Session * getSession() const
Definition: ThreadedSocketConnection.h:73
FIX::ThreadedSocketConnection::m_pSession
Session * m_pSession
Definition: ThreadedSocketConnection.h:96
FIX::ThreadedSocketConnection::m_sourceAddress
std::string m_sourceAddress
Definition: ThreadedSocketConnection.h:90
FIX::ThreadedSocketConnection::m_fds
fd_set m_fds
Definition: ThreadedSocketConnection.h:98
FIX::ThreadedSocketConnection::read
bool read()
Definition: ThreadedSocketConnection.cpp:114
Parser.h
FIX::ThreadedSocketConnection::m_sourcePort
int m_sourcePort
Definition: ThreadedSocketConnection.h:91
FIX::ThreadedSocketConnection::m_disconnect
bool m_disconnect
Definition: ThreadedSocketConnection.h:97
FIX::ThreadedSocketConnection::m_parser
Parser m_parser
Definition: ThreadedSocketConnection.h:94
FIX::ThreadedSocketConnection::connect
bool connect()
Definition: ThreadedSocketConnection.cpp:99
FIX
Definition: Acceptor.cpp:34
FIX::ThreadedSocketConnection::m_socket
int m_socket
Definition: ThreadedSocketConnection.h:85
FIX::ThreadedSocketConnection::ThreadedSocketConnection
ThreadedSocketConnection(int s, Sessions sessions, Log *pLog)
Definition: ThreadedSocketConnection.cpp:52
FIX::Parser
Parses FIX messages off an input stream.
Definition: Parser.h:53
FIX::ThreadedSocketConnection::m_buffer
char m_buffer[BUFSIZ]
Definition: ThreadedSocketConnection.h:86
Responder.h
FIX::SocketRecvFailed
Socket recv operation failed.
Definition: Exceptions.h:295
FIX::ThreadedSocketConnection::~ThreadedSocketConnection
virtual ~ThreadedSocketConnection()
Definition: ThreadedSocketConnection.cpp:77
FIX::ThreadedSocketConnection::m_pLog
Log * m_pLog
Definition: ThreadedSocketConnection.h:93
FIX::ThreadedSocketConnection::m_sessions
Sessions m_sessions
Definition: ThreadedSocketConnection.h:95
FIX::ThreadedSocketConnection::m_address
std::string m_address
Definition: ThreadedSocketConnection.h:88
FIX::Log
This interface must be implemented to log messages and events.
Definition: Log.h:98
FIX::Session
Maintains the state and implements the logic of a FIX session.
Definition: Session.h:62

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