From 6e5abd7fd879bdf3402a379efd8b8da5da4b2b26 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Thu, 21 May 2015 00:09:54 +1000 Subject: [PATCH] docs: port is optional for socket.bind() --- doc/api/dgram.markdown | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/api/dgram.markdown b/doc/api/dgram.markdown index 09bacaf098c1..fd7dde1dd5ed 100644 --- a/doc/api/dgram.markdown +++ b/doc/api/dgram.markdown @@ -156,19 +156,21 @@ a packet might travel, and that generally sending a datagram greater than the (receiver) `MTU` won't work (the packet gets silently dropped, without informing the source that the data did not reach its intended recipient). -### socket.bind(port[, address][, callback]) +### socket.bind([port][, address][, callback]) -* `port` Integer +* `port` Integer, Optional * `address` String, Optional * `callback` Function with no parameters, Optional. Callback when binding is done. For UDP sockets, listen for datagrams on a named `port` and optional -`address`. If `address` is not specified, the OS will try to listen on -all addresses. After binding is done, a "listening" event is emitted -and the `callback`(if specified) is called. Specifying both a -"listening" event listener and `callback` is not harmful but not very -useful. +`address`. +If `port` is not specified, the OS will try to bind to a random port. +If `address` is not specified, the OS will try to listen on all addresses. +After binding is done, a "listening" event is emitted and the `callback` +(if specified) is called. +Specifying both a "listening" event listenerand `callback` is not harmful +but not very useful. A bound datagram socket keeps the node process running to receive datagrams.