Fix heap corruption while destroying not inited connection and added support for socket timeout