Skip to content

Commit 58eeb23

Browse files
committed
Update docs on which sockets functions are proxied
1 parent 7410150 commit 58eeb23

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

site/source/docs/porting/networking.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Full POSIX Sockets over WebSocket Proxy Server
2929

3030
Emscripten provides a native POSIX Sockets proxy server program, located in directory tools/websocket_to_posix_proxy/, that allows full POSIX Sockets API access from a web browser. This support works by proxying all POSIX Sockets API calls from the browser to the Emscripten POSIX Sockets proxy server (via transparent use of WebSockets API), and the proxy server then performs the native TCP/UDP calls on behalf of the page. This allows a web browser page to run full TCP & UDP connections, act as a server to accept incoming connections, and perform host name lookups and reverse lookups. Because all API calls are individually proxied, this support can be slow. This support is mostly useful for developing testing infrastructure and debugging.
3131

32+
The following POSIX sockets functions are proxied in this manner:
33+
- `socket()`, `socketpair()`, `shutdown()`, `bind()`, `connect()`, `listen()`, `accept()`, `getsockname()`, `getpeername()`, `send()`, `recv()`, `sendto()`, `recvfrom()`, `sendmsg()`, `recvmsg()`, `getsockopt()`, `setsockopt()`, `getaddrinfo(), `getnameinfo()`.
34+
35+
The following POSIX sockets functions are currently not proxied (and will not work):
36+
- `poll()`, `close()` (use `shutdown()` instead), `select()`
37+
3238
To use POSIX sockets proxying, link the application with flags "-lwebsocket.js -s PROXY_POSIX_SOCKETS=1 -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1". That is, POSIX sockets proxying builds on top of the Emscripten WebSockets library, and requires multithreading and proxying the application main() to a pthread.
3339

3440
For an example of how the POSIX Sockets proxy server works in an Emscripten client program, see the file tests/websocket/tcp_echo_client.cpp.

0 commit comments

Comments
 (0)