开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: C++ preventing EReader reading when socket is closed


 

What makes me feel uneasy is that according to the documentation:



It makes users think that by calling eDisconnect() you can safely disconnect from TWS without causing errors but we have shown that this is not the case. You must "stop" the thread, then disconnect from the socket, in that order.

It is not possible for eDisconnect() to do that without creating a mutex locking system that shares mutexes between both EClientSocket and EReader. I agree with you that adding this complexity is not the right approach, for one as it will slow down the message receiving loop.

What I am opting for and will propose in the GitHub when I get the approval to create a branch, is creating an EReader::stop() function like this:



then modifying the destructor to the following:



Then I will also propose that the C++ documentation for the eDisconnect() function be changed to say that to disconnect safely you must call EReader::stop() before calling EClientSocket::eDisconnect().



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