From e5cc6388cbdfca14eadf0d89a4247db37af3e085 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 15 Nov 2010 20:26:46 -0800 Subject: [PATCH] Docs for server.address() --- doc/api/net.markdown | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/api/net.markdown b/doc/api/net.markdown index 3e1ec08..24d1e43 100644 --- a/doc/api/net.markdown +++ b/doc/api/net.markdown @@ -86,6 +86,25 @@ Stops the server from accepting new connections. This function is asynchronous, the server is finally closed when the server emits a `'close'` event. + +#### server.address() + +Returns the bound address of the server as seen by the operating system. +Useful to find which port was assigned when giving getting an OS-assigned address + +Example: + + var server = net.createServer(function (socket) { + socket.end("goodbye\n"); + }); + + // grab a random port. + server.listen(function() { + address = server.address(); + console.log("opened server on %j", address); + }); + + #### server.maxConnections Set this property to reject connections when the server's connection count gets high. -- 2.7.4