From f65f819f7fb3bbe9e24bc73342b4f335f5034fe0 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 12 Mar 2019 23:53:50 -0700 Subject: fixes #907 WebSocket ephemeral port cannot be reused --- tests/ws.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/ws.c b/tests/ws.c index e5cc8ba5..59d4d52d 100644 --- a/tests/ws.c +++ b/tests/ws.c @@ -155,5 +155,25 @@ TestMain("WebSocket Transport", { So(nng_dial(s2, "ws://127.0.0.1:5599/one", NULL, 0) == 0); }); + Convey("Wild card port works and can be used again", { + nng_socket s1; + nng_socket s2; + nng_listener l1; + int port; + char ws_url[128]; + So(nng_pair_open(&s1) == 0); + So(nng_pair_open(&s2) == 0); + Reset({ + nng_close(s1); + nng_close(s2); + }); + So(nng_listen(s1, "ws://*:0/one", &l1, 0) == 0); + So(nng_listener_getopt_int( + l1, NNG_OPT_TCP_BOUND_PORT, &port) == 0); + So(port != 0); + snprintf(ws_url, 1023, "ws://*:%d/two", port); + So(nng_listen(s2, ws_url, NULL, 0) == 0); + }); + nng_fini(); }) -- cgit v1.2.3-70-g09d2