Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/libsockfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ addToLibrary({
return FS.createNode(null, '/', {{{ cDefs.S_IFDIR | 0o777 }}}, 0);
},
createSocket(family, type, protocol) {
// Emscripten only supports AF_INET
if (family != {{{ cDefs.AF_INET }}}) {
throw new FS.ErrnoError({{{ cDefs.EAFNOSUPPORT }}});
}
type &= ~{{{ cDefs.SOCK_CLOEXEC | cDefs.SOCK_NONBLOCK }}}; // Some applications may pass it; it makes no sense for a single process.
// Emscripten only supports SOCK_STREAM and SOCK_DGRAM
if (type != {{{ cDefs.SOCK_STREAM }}} && type != {{{ cDefs.SOCK_DGRAM }}}) {
throw new FS.ErrnoError({{{ cDefs.EINVAL }}});
}
var streaming = type == {{{ cDefs.SOCK_STREAM }}};
if (streaming && protocol && protocol != {{{ cDefs.IPPROTO_TCP }}}) {
throw new FS.ErrnoError({{{ cDefs.EPROTONOSUPPORT }}}); // if SOCK_STREAM, must be tcp or 0.
Expand Down
12 changes: 12 additions & 0 deletions test/other/test_getifaddrs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <sys/types.h>
#include <ifaddrs.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>

int main() {
struct ifaddrs* ifaddrs = NULL;
int rtn = getifaddrs(&ifaddrs);
printf("getifaddrs => %d (%s)\n", rtn, strerror(errno));
return 0;
}
1 change: 1 addition & 0 deletions test/other/test_getifaddrs.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
getifaddrs => -1 (Address family not supported by protocol)
3 changes: 3 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -16092,3 +16092,6 @@ def test_em_js_bool_macro_expansion(self):
}
''')
self.do_runf('main.c')

def test_getifaddrs(self):
self.do_other_test('test_getifaddrs.c')