Skip to content

Commit 3952d11

Browse files
committed
Fix tcp_server::bind() to not throw despite returning error_code
tcp_server::bind() was documented to return std::error_code but internally called the throwing tcp_acceptor::listen() overload, violating its API contract. Add non-throwing listen() overloads to tcp_acceptor that take std::error_code& as the last parameter, following Boost.Asio conventions. The throwing overload now delegates to the non-throwing implementation. Changes: - Add tcp_acceptor::listen(endpoint, std::error_code&) - Add tcp_acceptor::listen(endpoint, int backlog, std::error_code&) - Update tcp_server::bind() to use the non-throwing overload - Add tests for success and failure paths using TEST-NET-1 addresses - Add test for listen() on already-open acceptor behavior
1 parent e56eb71 commit 3952d11

13 files changed

Lines changed: 591 additions & 507 deletions

File tree

‎doc/modules/ROOT/pages/guide/endpoints.adoc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ auto [ec] = co_await s.connect(target);
202202
[source,cpp]
203203
----
204204
corosio::tcp_acceptor acc(ioc);
205-
acc.listen(corosio::endpoint(8080)); // Bind to all interfaces
205+
if (auto ec = acc.listen(corosio::endpoint(8080))) // Bind to all interfaces
206+
return ec;
206207
----
207208

208209
== From Resolver Results

0 commit comments

Comments
 (0)