add try except for socket