fixed memory leak if socket fails connection in secure mode, added worka...

...round for TLS connections for iOS 5.0