Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting server IP within wasm application

I use C++ and Qt 5.15.x. I've built WebAssembly version of my desktop application. The application is loaded using URL like "http://192.168.21.55:5555" (intranet application). I'd like to extract server IP address within WebAssembly application. How can I achieve it?

like image 945
ilya Avatar asked Sep 19 '25 02:09

ilya


1 Answers

There is no solution for ip extraction, but I've found the way to get host and port (host is equal to ip in my case).

#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>());
like image 177
ilya Avatar answered Sep 21 '25 21:09

ilya