GazeApi disconnect sometimes throws
Posted: 28 Jun 2014, 23:57
In my application, I am frequently disconnecting from the server. It mostly works fine, but sometimes in gtl::Socket::disconnect( ), the call to boost::asio::ip::tcp::socket.close( ) throws a boost::system::system_error with code WSAENOTSOCK (10038).
I have tried uncommenting the shutdown( ) call, and then that guy just throws the error.
So I'm assuming there's some race condition where the underlying socket can be deleted or otherwise *poofed* but the
gtl::Socket object gets confused about this state.
I have worked around the issue by putting the boost close( ) inside a try block and catching boost::system::system_error. Because of another issue I have to delete the entire GazeApi every time after I disconnect anyway, so that will mask any issue that might arise from the state of the existing gtl::Socket object becoming confused.
I have tried uncommenting the shutdown( ) call, and then that guy just throws the error.
So I'm assuming there's some race condition where the underlying socket can be deleted or otherwise *poofed* but the
gtl::Socket object gets confused about this state.
I have worked around the issue by putting the boost close( ) inside a try block and catching boost::system::system_error. Because of another issue I have to delete the entire GazeApi every time after I disconnect anyway, so that will mask any issue that might arise from the state of the existing gtl::Socket object becoming confused.
- Code: Select all
try
{
//gjb why was this commented out?
m_socket.shutdown(boost::asio::socket_base::shutdown_type::shutdown_both);
m_socket.close();
}
catch(boost::system::system_error e)
{
fprintf(stderr, "socket close caught error %d\n", e.code());
}