fixed memory leak and did some prework to support multiple socket types for ssl