forked from nodejscn/node-api-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9879c3f
commit 5fd60c0
Showing
9 changed files
with
30 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
|
||
> Stability: 2 - Stable | ||
> 稳定性: 2 - 稳定的 | ||
|
||
<!-- name=dgram --> | ||
|
||
The `dgram` module provides an implementation of UDP Datagram sockets. | ||
`dgram`模块提供了 UDP 数据包 socket 的实现。 | ||
|
||
```js | ||
const dgram = require('dgram'); | ||
const server = dgram.createSocket('udp4'); | ||
server.on('error', (err) => { | ||
console.log(`server error:\n${err.stack}`); | ||
console.log(`服务器异常:\n${err.stack}`); | ||
server.close(); | ||
}); | ||
server.on('message', (msg, rinfo) => { | ||
console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`); | ||
console.log(`服务器收到:${msg} 来自 ${rinfo.address}:${rinfo.port}`); | ||
}); | ||
server.on('listening', () => { | ||
var address = server.address(); | ||
console.log(`server listening ${address.address}:${address.port}`); | ||
console.log(`服务器监听 ${address.address}:${address.port}`); | ||
}); | ||
server.bind(41234); | ||
// server listening 0.0.0.0:41234 | ||
// 服务器监听 0.0.0.0:41234 | ||
``` | ||
|