diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 08f24d9f..402e4a79 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -375,15 +375,20 @@ int _mosquitto_try_connect(struct mosquitto *mosq, const char *host, uint16_t po #ifdef WITH_TLS int mosquitto__socket_connect_tls(struct mosquitto *mosq) { - int ret; - + int ret, err; ret = SSL_connect(mosq->ssl); - if(ret != 1){ - ret = SSL_get_error(mosq->ssl, ret); - if(ret == SSL_ERROR_WANT_READ){ + if(ret != 1) { + err = SSL_get_error(mosq->ssl, ret); +#ifdef WIN32 + if (err == SSL_ERROR_SYSCALL) { + mosq->want_connect = true; + return MOSQ_ERR_SUCCESS; + } +#endif + if(err == SSL_ERROR_WANT_READ){ mosq->want_connect = true; /* We always try to read anyway */ - }else if(ret == SSL_ERROR_WANT_WRITE){ + }else if(err == SSL_ERROR_WANT_WRITE){ mosq->want_write = true; mosq->want_connect = true; }else{