NodeJS 创建TCP服务器

来源:互联网 发布:linux hba卡查看 编辑:程序博客网 时间:2024/06/11 21:09
var net = require("net");var server = net.createServer(function(socket){socket.on("data",function(){socket.write("server:  client is connected the ip address is " + socket.remoteAddress);});socket.on("end",function(){console.log("连接断开");});socket.on("drain",function(){console.log("write data is clear");});});server.listen(8124,function(){console.log("server bound");});

0 0