cesanta/mongoose — pull request #378 by cry-inc (2014-05-27 14:28:02+00:00)
Title: Return the correct listening_port when binding to an IP with port 0

mg_set_option(server, "listening_port", "127.0.0.1:0") works like intended, binding the server to the local host only and selecting a random free port. But mg_get_option(server, "listening_port") will return "127.0.0.1:0" instead of "127.0.0.1:50230" or whatever port was used. The attached patch fixes this behavior and makes it possible to retrieve the real port. The buffer is 60 bytes large to host any IPV6 address (max 45 chars) + 15 additional chars for the port number and the colon.