41#define BLACKHOLE_HOST "192.0.2.1"
43#define BLACKHOLE_PORT "80"
45#define LONG_CONNECT_TIMEOUT_MS 20000
47#define ABORT_MAX_MS 3000
72 time_t elapsed_us =
get_usec(&timer);
73 long elapsed_ms = (long)(elapsed_us / 1000);
100 elapsed_ms = (long)(
get_usec(&timer) / 1000);
107 n_log(
LOG_ERR,
"FAIL: callback polled after being removed");
114 n_log(
LOG_INFO,
"ex_network_connect_abort: all checks passed");
116 n_log(
LOG_ERR,
"ex_network_connect_abort: %d check(s) FAILED", fails);
117 return fails ? 1 : 0;
NETWORK * netw
Network for server mode, accepting incomming.
#define ABORT_MAX_MS
An aborted connect must return in well under the connect budget.
static int abort_now(void *ctx)
Connect-abort callback that always asks to abort, counting its polls.
static int g_polls
Count of times the abort callback was polled (proves it ran).
#define BLACKHOLE_PORT
Blackhole port (any).
#define LONG_CONNECT_TIMEOUT_MS
Long connect budget so an un-aborted attempt would clearly out-last an aborted one.
#define BLACKHOLE_HOST
Blackhole target: RFC 5737 documentation range, never has a listener.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_INFO
informational
int start_HiTimer(N_TIME *timer)
Initialize or restart from zero any N_TIME HiTimer.
time_t get_usec(N_TIME *timer)
Poll any N_TIME HiTimer, returning usec, and moving currentTime to startTime.
#define NETWORK_IPV4
Flag to force IPV4
int netw_close(NETWORK **netw)
Closing a specified Network, destroy queues, free the structure.
int netw_connect_to(NETWORK **netw, char *host, char *port, int ip_version, int connect_timeout_ms)
Connect a NETWORK with a bounded connection-establishment time.
void netw_set_connect_abort_cb(int(*cb)(void *ctx), void *ctx)
Register a process-wide callback polled while a connect is in progress.