MCPcopy Create free account
hub / github.com/COVESA/vsomeip / start

Method start

implementation/endpoints/src/tcp_server_endpoint_impl.cpp:112–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void tcp_server_endpoint_impl::start() {
113 VSOMEIP_INFO_P << instance_name_;
114
115 std::scoped_lock its_lock(acceptor_mutex_);
116 if (acceptor_->is_open()) {
117 connection::ptr new_connection =
118 connection::create(std::dynamic_pointer_cast<tcp_server_endpoint_impl>(shared_from_this()), max_message_size_,
119 buffer_shrink_threshold_, use_magic_cookies_, io_, send_timeout_);
120
121 tcp_socket& tmp_socket = new_connection->get_socket();
122
123 // Use the peer-endpoint overload so the remote address is captured by the kernel
124 // at accept() time. If the client disconnects immediately after connecting, calling
125 // remote_endpoint() on the socket in the callback would fail (returning an unspecified
126 // address), which would later cause messages to be dropped in on_message.
127 auto its_remote_ep = std::make_shared<endpoint_type>();
128 acceptor_->async_accept(tmp_socket, *its_remote_ep,
129 [self = shared_from_this(), new_connection, its_remote_ep](const boost::system::error_code& _ec) {
130 std::dynamic_pointer_cast<tcp_server_endpoint_impl>(self)->accept_cbk(new_connection, its_remote_ep,
131 _ec);
132 });
133 } else {
134 VSOMEIP_ERROR_P << instance_name_ << "Start failed, acceptor is closed";
135 }
136
137 VSOMEIP_INFO_P << instance_name_ << "Done";
138}
139
140void tcp_server_endpoint_impl::stop(bool /*_due_to_error*/) {
141 VSOMEIP_INFO_P << instance_name_;

Callers 1

accept_cbkMethod · 0.45

Calls 3

is_openMethod · 0.45
async_acceptMethod · 0.45
accept_cbkMethod · 0.45

Tested by

no test coverage detected