Hello All,
I want to do Synchronous http request ,and have tried the following ways :
1銆乥uild the licurl into bitcode ,it failed when call function select(err code :timeout);
2銆乼hen i tried emscripten_wget_data funtion ,but when i use -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 along with option -s USE_PTHREADS=1,it reports some err when compile the project;

3銆乼hen i tried emscripten_async_wget2_data ,but how can i do synchronouse.
How can i use libcurl in emscripten?Or any other ideas for my issue ?
Any help is welcome!
I don't know about using C calls only,
but I usually do it like this :
emscripten_run_script(R"(
var request = new XMLHttpRequest();
request.open("GET", "something", false);
request.onload = function (oEvent) {
// do something
};
)");
At the moment -s EMTERPRETER>0 and -s USE_PTHREADS>0 cannot be used simultaneously. Pushed a commit to improve the error message so it will be explicitly clear. I'm not familiar enough with Emterpreter to figure out if it would be possible to pair with pthreads mode, perhaps @kripken would know. The error message seems to be that Emterpreter fails on when it sees HEAP32 as a parameter to an atomic intrinsic, which it doesn't expect.
Although for your use, I don't think you'd even want to pair these two build flags together(?)
Not sure about libcurl either if someone might have had success in compiling it. Generally either the synchronous browser XHRs as shown by @gogoprog or emterpreted synchronous emscripten wgets are the way to go. In the moderate to near future, Emscripten Fetch will also allow synchronous XHRs (see the current work in progress PR #4553)
It's possible to use an asynchronous fetch in a synchronous way with Emterpreter-Async by sleeping and waiting for the callbacks to set a flag. I'm doing it here. It may be ugly, but it works.
This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
Most helpful comment
I don't know about using C calls only,
but I usually do it like this :