请教:WebSocket如何获取客户端IP
WebSocket刚接触,服务建立起来后如何获取客服端IP地址, 我需要知道是谁请求的?server,socket,header,conn…都翻遍了,哪个对象里面有Remote Address?
var ws = require(“nodejs-websocket”);
var server = ws.createServer(function(conn){
console.log(conn);
conn.on(“text”, function (str) {
console.log(“Socket对象”);
console.log(conn.socket);
console.log(“Headers对象”);
console.log(conn.headers);
console.log("path对象");
console.log(conn.path);
console.log("server对象");
console.log(server);
5 回复