Skip to content

Commit

Permalink
-s PROXY_POSIX_SOCKETS option: Allows POSIX sockets support via proxy…
Browse files Browse the repository at this point in the history
…ing the calls out to a sockets proxy bridge via WebSockets
  • Loading branch information
juj committed Dec 14, 2018
1 parent 3187922 commit 473d614
Show file tree
Hide file tree
Showing 17 changed files with 3,874 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -3234,6 +3234,7 @@ LibraryManager.library = {
// arpa/inet.h
// ==========================================================================

#if PROXY_POSIX_SOCKETS == 0
// old ipv4 only functions
inet_addr__deps: ['_inet_pton4_raw'],
inet_addr: function(ptr) {
Expand Down Expand Up @@ -3976,6 +3977,8 @@ LibraryManager.library = {
0x0b00000a, 0x0c00000a, 0x0d00000a, 0x0e00000a] /* 0x0100000a is reserved */
},

#endif // PROXY_POSIX_SOCKETS == 0

// pwd.h

getpwnam: function() { throw 'getpwnam: TODO' },
Expand Down
3 changes: 3 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ var SOCKET_WEBRTC = 0;
// where addr and port are derived from the socket connect/bind/accept calls.
var WEBSOCKET_URL = 'ws://';

// If 1, the POSIX sockets API uses a proxy bridge to proxy sockets calls
var PROXY_POSIX_SOCKETS = 0;

// A string containing a comma separated list of WebSocket subprotocols
// as would be present in the Sec-WebSocket-Protocol header.
var WEBSOCKET_SUBPROTOCOL = 'binary';
Expand Down
13 changes: 13 additions & 0 deletions system/include/emscripten/posix_socket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "websocket.h"

#ifdef __cplusplus
extern "C" {
#endif

extern EMSCRIPTEN_RESULT emscripten_init_websocket_to_posix_socket_bridge(const char *bridgeUrl);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 473d614

Please sign in to comment.