added two functions to create and destroy socket