fix socket exception handling