I am crating SSL socket and when I try to connect to that socket my program hangs.
I found some issue that server does not send any data so SSL connection is waiting for the any response.
I decided to create future and kill it after timeout. But it is still hanging.
If you see to the code, below part is not executed: cout<<"TEST";
{
std::future<void> future = std::async(std::launch::async,
[&](){
err = SSL_connect (m_ssl);
});
std::future_status status;
status = future.wait_for(std::chrono::seconds(t_timeout));
}
cout<<"TEST";
To simulate stopping response from server I just run:
for item in $(seq 1 1000); do sudo nc -i 100000ms -l 443 >> log.out; done;
How do I kill the SSL connection? I want to continue execution of code after kill the future.
EDIT: I do not want to open another question for that. Answer: So i am sure now that this is because of future destructor. It is waiting for finish of code from the future body.
Question 2: How Can I fix above issue? I want to execute code after scope which future is in.
Is it OK to create thread and wait until timeout or ssl some mutex is unlocked?