From ecfff63e06e77e22035a7f7caa26986f033f3aea Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sat, 12 Mar 2022 00:25:14 +0200 Subject: bpo-40280: Disable AF_UNIX, AF_PACKET, SO_REUSE* on Emscripten (#31829) Emscripten's socket emulation is limited. AF_UNIX, AF_PACKET, setsockopt(), and most SO_* constants are not supported. --- Modules/socketmodule.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Modules/socketmodule.h') diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h index db26c046c3..1b35b11cde 100644 --- a/Modules/socketmodule.h +++ b/Modules/socketmodule.h @@ -192,6 +192,21 @@ typedef int socklen_t; #endif /* HAVE_SOCKADDR_ALG */ +#ifdef __EMSCRIPTEN__ +// wasm32-emscripten sockets only support subset of IPv4 and IPv6. +// SCTP protocol crashes runtime. +#ifdef IPPROTO_SCTP +# undef IPPROTO_SCTP +#endif +// setsockopt() fails with ENOPROTOOPT, getsockopt only supports SO_ERROR. +// undef SO_REUSEADDR and SO_REUSEPORT so they cannot be used. +#ifdef SO_REUSEADDR +# undef SO_REUSEADDR +#endif +#ifdef SO_REUSEPORT +# undef SO_REUSEPORT +#endif +#endif // __EMSCRIPTEN__ #ifndef Py__SOCKET_H #define Py__SOCKET_H -- cgit v1.2.1