Repository navigation
Commit ba7f418
committed
Fix tcp_server::bind() to use non-throwing listen()
tcp_server::bind() could throw because tcp_acceptor::listen() had
throwing overloads. This changes listen() to return [[nodiscard]]
std::error_code, allowing bind() to properly propagate errors without
throwing.
API change for tcp_acceptor::listen():
Before: void listen(endpoint, int backlog = 128) // throws
void listen(endpoint, std::error_code&) // out-param
void listen(endpoint, int, std::error_code&) // out-param
After: [[nodiscard]] std::error_code listen(endpoint, int backlog = 128)
The [[nodiscard]] attribute ensures callers cannot accidentally ignore
errors. This aligns with signal_set and socket options which already
use non-throwing return values.
Changes:
- Fix tcp_server::bind() to capture and return listen() error code
- Consolidate tcp_acceptor::listen() to single non-throwing overload
- Document error conditions (address_in_use, address_not_available,
permission_denied, operation_not_supported) and @throws Nothing
- Update test utilities (socket_pair, mocket) with error checks
- Update all unit tests (~20 call sites) to check return values
- Update documentation (tcp_acceptor.adoc, tls.adoc, signals.adoc,
endpoints.adoc) with new error-handling pattern1 parent e56eb71 commit ba7f418
13 files changed
Lines changed: 602 additions & 507 deletions
File tree
- doc/modules/ROOT/pages/guide
- include/boost/corosio
- src/corosio/src
- test
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| |||
0 commit comments