13#include <boost/asio/io_context.hpp>
14#include <boost/asio/ip/tcp.hpp>
15#include <boost/asio/post.hpp>
28 using endpoint = boost::asio::ip::tcp::endpoint;
45 template <
typename FunctorT1,
typename FunctorT2>
46 void Listen(FunctorT1 on_session_opened, FunctorT2 on_session_closed) {
50 std::move(on_session_opened),
51 std::move(on_session_closed));
包含Carla流处理模块中TCP通信相关类的头文件依赖。
std::function< void(std::shared_ptr< ServerSession >)> callback_function_type
回调函数类型别名。
警告:在io_context停止之前,不能销毁这个服务器实例
endpoint::protocol_type protocol_type
bool IsSynchronousMode() const
boost::asio::io_context & _io_context
void SetTimeout(time_duration timeout)
设置会话超时时间,仅对新创建的会话有效,默认为10秒
boost::asio::ip::tcp::endpoint endpoint
endpoint GetLocalEndpoint() const
void OpenSession(time_duration timeout, ServerSession::callback_function_type on_session_opened, ServerSession::callback_function_type on_session_closed)
void Listen(FunctorT1 on_session_opened, FunctorT2 on_session_closed)
Server(boost::asio::io_context &io_context, endpoint ep)
std::atomic< time_duration > _timeout
boost::asio::ip::tcp::acceptor _acceptor
void SetSynchronousMode(bool is_synchro)
Positive time duration up to milliseconds resolution.