diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-10-01 13:11:41 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-12-15 17:06:11 +0100 |
commit | 76d12eea2252c5e537dff15b103bdc1f925cf760 (patch) | |
tree | 30bf5a17f560268d334cfa46228639f0ab77c68e /src/network/socket/qnativesocketengine.cpp | |
parent | 292bdac4cfaebcc905975aa0cdc2f87782c389f6 (diff) |
wasm: implement host lookup for socket tunneling
Emscripten implements support for tunneling TCP and
UDP sockets through a WebSockets connection. This support
is implement for the BSD sockets API, which means that
Qt’s existing socket classes can be used, with some
adjustments.
For example, the flow for making a TCP connection to
example.com:1515 can look like this:
1) The application resolves “example.com”.
Emscripten creates an internal mapping to a private
IP and returns that IP: 172.29.1.0.
2) The application connects to 172.29.1.0:1515.
Emscripten makes a WebSocket connection to example.com:1515,
and forwards the TCP data over this connection
3) On example.com:1515, a WebSockify intermediate server
accepts the WebScoket connection and forwards the
TCP data to the target sever, as specified by the
WebSockify configuration.
Emscripten’s local getaddrinfo() implementation is fast,
which means don’t need caching or the thread pool. Instead,
special-case lookupHostImpl() for Q_OS_WASM. The implementation
calls QHostInfoAgent::lookup() and then posts resultReady
using QHostInfoResult.
Change-Id: Iaf31efb701ae7cc11752a63cc6b8346d4f09107e
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/network/socket/qnativesocketengine.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index f70e34c375..dfc8d96821 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -476,11 +476,13 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb } +#ifndef Q_OS_WASM // Make sure we receive out-of-band data if (socketType == QAbstractSocket::TcpSocket && !setOption(ReceiveOutOfBandData, 1)) { qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data"); } +#endif // Before Qt 4.6, we always set the send and receive buffer size to 49152 as // this was found to be an optimal value. However, modern OS |