diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index e1ec858ef04..d9f234d4192 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "emscripten.h" #include @@ -337,6 +338,14 @@ void QEventDispatcherWasm::registerSocketNotifier(QSocketNotifier *notifier) g_socketNotifiers.insert({notifier->socket(), notifier}); if (wasEmpty) runOnMainThread([] { setEmscriptenSocketCallbacks(); }); + + int count; + ioctl(notifier->socket(), FIONREAD, &count); + + // message may have arrived already + if (count > 0 && notifier->type() == QSocketNotifier::Read) { + QCoreApplication::postEvent(notifier, new QEvent(QEvent::SockAct)); + } } void QEventDispatcherWasm::unregisterSocketNotifier(QSocketNotifier *notifier)