Replaced raw ptr with shared_ptr for ip, no need for close method