简体   繁体   中英

How get IP address before connecting on server client (use websockets/ws)?

在服务器客户端上连接之前如何获取IP地址(使用websockets / ws)?

var webSocketServer = new WebSocketServer.Server({port: 8081, verifyClient: function(info, callback) { });

You can't get the IP address of a client before it connects. Before the connection, there is no contact at all between client and server and thus the server has no idea which client will connect some time in the future. It would literally be any client in the world.

If you explain what you're really trying to accomplish we might be able to help you solve your problem better.

I assume you are looking for client's IP address. One of the ways to get it

websocket._socket.remoteAddress

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM