¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Building up a C++ Client


 

Did you try the IB exemple ?

From your code I wonder where is the reader thread launched. look for eConnectImpl and see what is inside
Raw from my notes: (written as ongoing job, not sure 100% accurate and can be cryptic)
/* Discussion:

The IB telco is not perfectly thread safe
I feel the "connect" is not safe enough to re-connect from within a thread.
need a lock to avoid 2 connect at same time on same gate_c

gate_c connection Principle
1- Create a connection
bool gate_c::connect()
?? ?m_pClient->eConnect(m_sHost.c_str(), m_iPort, m_iClientId, m_extraAuth);
?

2- Open a connection actutator
?? ?EClientSocket::eConnectImpl(int clientId, bool extraAuth, ConnState* stateOutPt)
?? ?which contain the
?? ?m_fd = (int /*glh++* /)socket(AF_INET, SOCK_STREAM, 0);
?? ?and the
?? ?if( (connect( m_fd, (struct sockaddr *) &sa, sizeof( sa))) < 0)
?? ?
3- See EClientSocket::eConnectImpl needed to get a first request sent
?? ?it use a heap EReader one time use to get Server version
?? ?Note: EReader object are protected by it's own Mutex m_csMsgQueue for thread safety.
?? ?And use a std::unique_ptr<ETransport> to access Connection info
?? ?See EReader::putMessageToQueue()
?? ????
4- Create the official permanent "reader"
?? ?m_pReader = new EReader
?? ?m_pReader->start();
?? ?
5- Which Launch independant reader thread
?? ?m_hReadThread = CreateThread(0, 0, readToQueueThread, this, 0, 0);

6- ??? Writer is part of Main thread that own gate_c
?? ?Reader have it's own recv then dispatch.


Note:
EReader reader can be used in main thread if not calling ->start()
Note:
EReader object are protected by there own Mutex m_csMsgQueue for thread safety.

*/

Join [email protected] to automatically receive all group messages.