Warm tip: This article is reproduced from serverfault.com, please click

javascript-在wasm应用程序中获取服务器IP

(javascript - Getting server IP within wasm application)

发布于 2020-12-15 07:20:53

我使用C ++和Qt5.15.x。我已经构建了桌面应用程序的WebAssembly版本。该应用程序是使用“ http://192.168.21.55:5555”之类的URL加载的(内部网应用程序)。我想在WebAssembly应用程序中提取服务器IP地址。我该如何实现?

Questioner
ilya
Viewed
0
ilya 2021-01-13 17:59:14

没有用于ip提取的解决方案,但是我已经找到了获取主机和端口的方法(在我的情况下,host等于ip)。

#include <emscripten/val.h>
emscripten::val location = emscripten::val::global("location");
auto host = QString::fromStdString(location["host"].as<std::string>());
auto port = QString::fromStdString(location["port"].as<std::string>());