Replace socket_handler::fill_buffer() recursion with loop (#8389)