qicosmos / rest_rpc

modern C++(C++11), simple, easy to use rpc framework
MIT License
1.66k stars 365 forks source link

端口复用问题 #62

Open chenzl-123 opened 2 years ago

chenzl-123 commented 2 years ago

terminate called after throwing an instance of 'boost::wrapexcept' what(): bind: Address already in use 在linux底下杀掉进程再重新启动进程,会提示端口被复用,这个要怎么加入可复用的参数

qicosmos commented 2 years ago

是最新的代码测试出现的吗?

Codecing commented 1 year ago

terminate called after throwing an instance of 'boost::wrapexceptboost::system::system_error' what(): bind: Address already in use 在linux底下杀掉进程再重新启动进程,会提示端口被复用,这个要怎么加入可复用的参数

class rpc_server : private asio::noncopyable { public: rpc_server(unsigned short port, size_t size, size_t timeout_seconds = 15, size_t check_seconds = 10) : io_servicepool(size), acceptor_(io_servicepool.get_io_service(), tcp::endpoint(tcp::v4(), port)), timeoutseconds(timeout_seconds), checkseconds(checkseconds) { fcntl(acceptor.native_handle(), F_SETFD, FD_CLOEXEC);// 设置 socket FD_CLOEXEC属性,避免多进程端口占用 do_accept(); checkthread = std::make_shared([this] { clean(); }); pub_subthread = std::make_shared([this] { clean_sub_pub(); }); }