简体   繁体   中英

For websocket connection in javascript if wants to communicate to other device how I can get IP address which I can pass through websocket connection?

var ip = ""; 
var ws = new WebSocket("ws://"+ip+":9998");

It is not possible to find private IP address. or I need any server side language like node.js?

You would need to know the IP address in order to do that. There is no way of figuring out the IP address of other clients. If you wanted to connect to another socket without knowing the IP address you would use a server to connect the endpoints and route the messages.

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