32 const char* what = udp ?
"netw_bind_udp" :
"netw_make_listening";
38 for (p = 34100; p < 34100 + 200; p++) {
39 snprintf(
port,
sizeof(
port),
"%d", p);
47 n_log(
LOG_ERR,
"%s: could not take any port in the test range", what);
63 "%s: the SECOND bind to port %s SUCCEEDED. The port is being shared, so a "
64 "listener can be started over one another process already owns.",
68 n_log(
LOG_INFO,
"%s: a second bind to port %s was refused, as it must be", what,
port);
82 "%s: the second UDP bind to port %s SUCCEEDED on Windows, where the port "
83 "should be exclusive",
87 n_log(
LOG_INFO,
"%s: a second UDP bind to port %s was refused, as it must be on Windows", what,
port);
90 "%s: a second UDP bind to port %s %s, which is what POSIX SO_REUSEADDR means "
91 "for datagram sockets (shared receivers); the exclusivity that matters is "
92 "asserted for TCP above and for UDP on Windows",
93 what,
port, ok ?
"succeeded" :
"was refused");
105 "ex_bind_exclusive: a TCP listener's port is exclusive; UDP is exclusive on Windows "
106 "and shareable on POSIX, which is what SO_REUSEADDR means there\n");
108 printf(
"ex_bind_exclusive: FAILED\n");
static int check_exclusive(int udp)
Bind a listener, then try to bind the same port again; the second must fail.
#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 netw_bind_udp(NETWORK **netw, char *addr, char *port, int ip_version)
Create a UDP bound socket for receiving datagrams.
int netw_make_listening(NETWORK **netw, char *addr, char *port, int nbpending, int ip_version)
Make a NETWORK be a Listening network.
#define NETWORK_IPV4
Flag to force IPV4.
int netw_close(NETWORK **netw)
Closing a specified Network, destroy queues, free the structure.