set socket file descriptor to 0 in close function