Node.js net模块如何实现长尾词事件监听功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计798个文字,预计阅读时间需要4分钟。
本文实例讲述了Node.js net模块功能及事件监听用法。分享给大家供大家参考,具体如下:
net模块
对比C语言的网络编程,Node.js有更加简便的开发模式与模块提供。它就是net模块
在需要使用的时候只需要require("net")就可以引入模块了。
var net = require("net");
服务端编程
引入模块的前提下:
1. 创建一个新的TCP或IPC服务
var server = net.createServer(function(client_socket) { console.log("client coming"); });
2. 创建connections 启动一个 server 监听.
server.listen({ host:'127.0.0.1', port:6080, exclusive:true, });
客户端编程
引入net模块。
本文共计798个文字,预计阅读时间需要4分钟。
本文实例讲述了Node.js net模块功能及事件监听用法。分享给大家供大家参考,具体如下:
net模块
对比C语言的网络编程,Node.js有更加简便的开发模式与模块提供。它就是net模块
在需要使用的时候只需要require("net")就可以引入模块了。
var net = require("net");
服务端编程
引入模块的前提下:
1. 创建一个新的TCP或IPC服务
var server = net.createServer(function(client_socket) { console.log("client coming"); });
2. 创建connections 启动一个 server 监听.
server.listen({ host:'127.0.0.1', port:6080, exclusive:true, });
客户端编程
引入net模块。

