lujieting
// ip 地址用来定位计算机
// 端口号用来定位具体的应用程序
// 所有需要联网通信的应用程序都会占用一个端口号

var http = require(\'http\')

var server = http.createServer()

// 2. 监听 request 请求事件,设置请求处理函数
server.on(\'request\', function (req, res) {
console.log(\'收到请求了,请求路径是:\' + req.url)
console.log(\'请求我的客户端的地址是:\', req.socket.remoteAddress, req.socket.remotePort)

res.end(\'hello nodejs\')
})

server.listen(5000, function () {
console.log(\'服务器启动成功,可以访问了。。。\')
})

分类:

技术点:

相关文章:

  • 2021-10-06
  • 2021-06-22
  • 2021-10-12
  • 2021-12-03
  • 2021-09-05
  • 2021-09-10
  • 2021-11-23
猜你喜欢
  • 2021-09-16
  • 2022-01-14
  • 2021-12-03
  • 2022-12-23
  • 2021-12-03
  • 2021-06-04
相关资源
相似解决方案