created functions for creating socket objects and connecting