![]() |
![]() |
|
Index
Source Files
Annotated Class List
Alphabetical Class List
Class Hierarchy
Graphical Class Hierarchy
|
||
![]() |
![]() |
00001 /* -*- C++ -*- */ 00002 00003 /**************************************************************************** 00004 ** Copyright (c) quickfixengine.org All rights reserved. 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_SOCKETCONNECTION_H 00023 #define FIX_SOCKETCONNECTION_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 "SocketMonitor.h" 00033 #include <set> 00034 00035 namespace FIX 00036 { 00037 class SocketAcceptor; 00038 class SocketServer; 00039 class SocketConnector; 00040 class SocketInitiator; 00041 class Session; 00042 00044 class SocketConnection : Responder 00045 { 00046 public: 00047 typedef std::set<SessionID> Sessions; 00048 00049 SocketConnection( int s, Sessions sessions, SocketMonitor* pMonitor ); 00050 SocketConnection( SocketInitiator&, const SessionID&, int, SocketMonitor* ); 00051 virtual ~SocketConnection(); 00052 00053 int getSocket() const { return m_socket; } 00054 Session* getSession() const { return m_pSession; } 00055 00056 bool read( SocketConnector& s ); 00057 bool read( SocketAcceptor&, SocketServer& ); 00058 bool processQueue(); 00059 00060 void signal() 00061 { 00062 Locker l( m_mutex ); 00063 if( m_sendQueue.size() == 1 ) 00064 m_pMonitor->signal( m_socket ); 00065 } 00066 00067 void unsignal() 00068 { 00069 Locker l( m_mutex ); 00070 if( m_sendQueue.size() == 0 ) 00071 m_pMonitor->unsignal( m_socket ); 00072 } 00073 00074 void onTimeout(); 00075 00076 private: 00077 typedef std::deque<std::string> 00078 Queue; 00079 00080 bool isValidSession(); 00081 void readFromSocket() throw( SocketRecvFailed ); 00082 bool readMessage( std::string& msg ); 00083 void readMessages( SocketMonitor& s ); 00084 bool send( const std::string& ); 00085 void disconnect(); 00086 00087 int m_socket; 00088 char m_buffer[BUFSIZ]; 00089 00090 Parser m_parser; 00091 Queue m_sendQueue; 00092 unsigned m_sendLength; 00093 Sessions m_sessions; 00094 Session* m_pSession; 00095 SocketMonitor* m_pMonitor; 00096 Mutex m_mutex; 00097 fd_set m_fds; 00098 }; 00099 } 00100 00101 #endif //FIX_SOCKETCONNECTION_H
1.3.6-20040222 written by Dimitri van Heesch,
© 1997-2001