5 ex_network_connect_abort_8c example
gullradriel edited this page 2026-10-09 00:51:57 +02:00

ex_network_connect_abort.c

Interrupt an in-progress connect with netw_set_connect_abort_cb. A connect to an unresponsive host (a dropped SYN) otherwise blocks until the connect timeout. Registering a connect-abort callback makes the connect wait wake every NETW_CONNECT_ABORT_POLL_MS to poll it, so returning non-zero from the callback aborts the attempt at once. This example dials a TEST-NET-1 (RFC 5737, 192.0.2.0/24, not routed) address, which is guaranteed to have no listener, with a long connect timeout and a callback that asks to abort: the connect returns promptly rather than after the timeout.