fix socket close and bufferings