Node.js核心模块-net

net.Socket 类

socket.remotePort

访问服务器的远程端口

const http = require('http');
const server = http.createServer((req, res) => {
    console.log(`端口是${req.socket.remotePort}`)
}).listen(3002)

socket.remoteAddress

访问服务器的远程ip地址

const server = http.createServer((req, res) => {
    console.log(`端口是${req.socket.remoteAddress}`)
}).listen(3002)
posted @ 2020-01-02 19:33  懒懒同学不懒  阅读(159)  评论(0编辑  收藏  举报