close socket every time it is used