Skip to content

Commit

Permalink
Update dgram_createsocket_options_callback.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wangdejun authored Dec 24, 2017
1 parent 257922f commit a4354a5
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions dgram/dgram_createsocket_options_callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@ changes:
supported now.
-->

* `options` {Object} Available options are:
* `type` {string} The family of socket. Must be either `'udp4'` or `'udp6'`.
Required.
* `reuseAddr` {boolean} When `true` [`socket.bind()`][] will reuse the
address, even if another process has already bound a socket on it.
Defaults to `false`.
* `recvBufferSize` {number} - Sets the `SO_RCVBUF` socket value.
* `sendBufferSize` {number} - Sets the `SO_SNDBUF` socket value.
* `lookup` {Function} Custom lookup function. Defaults to [`dns.lookup()`][].
* `callback` {Function} Attached as a listener for `'message'` events. Optional.
* Returns: {dgram.Socket}
* `options` {Object} 允许的选项是:
 * `type` {string} 套接字族. 必须是 `'udp4'`  `'udp6'`.
   必需填.
 * `reuseAddr` {boolean} 若设置为 `true` [`socket.bind()`][] ,则会
   重用地址,即时另一个进程已经在其上面绑定了一个套接字。
   默认是 `false`.
 * `recvBufferSize` {number} - 设置 `SO_RCVBUF` 套接字值。
 * `sendBufferSize` {number} - 设置 `SO_SNDBUF` 套接字值。
 * `lookup` {Function} 惯常的查询函数. 默认是 [`dns.lookup()`][]
* `callback` {Function} 为 `'message'` 事件绑定一个监听器。可选。
* 返回: {dgram.Socket}
Creates a `dgram.Socket` object. Once the socket is created, calling
[`socket.bind()`][] will instruct the socket to begin listening for datagram
messages. When `address` and `port` are not passed to [`socket.bind()`][] the
method will bind the socket to the "all interfaces" address on a random port
(it does the right thing for both `udp4` and `udp6` sockets). The bound address
and port can be retrieved using [`socket.address().address`][] and
[`socket.address().port`][].
创建一个 `dgram.Socket` 对象. 一旦创建了套接字,调用
[`socket.bind()`][] 会指示套接字开始监听数据报消息。如果 `address` 和 `port` 没传给  [`socket.bind()`][],
那么这个方法会把这个套接字绑定到 "全部接口" 地址的一个随机端口(这适用于 `udp4` 和 `udp6` 套接字)。
绑定的地址和端口可以通过 [`socket.address().address`][] 和[`socket.address().port`][] 来获取。

0 comments on commit a4354a5

Please sign in to comment.