1 // Copyright (c) 2015-2017 Nuxi, https://nuxi.nl/
3 // SPDX-License-Identifier: BSD-2-Clause
5 #include <sys/socket.h>
12 static_assert(MSG_PEEK
== __WASI_RIFLAGS_RECV_PEEK
, "Value mismatch");
13 static_assert(MSG_WAITALL
== __WASI_RIFLAGS_RECV_WAITALL
, "Value mismatch");
15 ssize_t
recv(int socket
, void *restrict buffer
, size_t length
, int flags
) {
17 if ((flags
& ~(MSG_PEEK
| MSG_WAITALL
)) != 0) {
22 // Prepare input parameters.
23 __wasi_iovec_t iov
= {.buf
= buffer
, .buf_len
= length
};
24 __wasi_iovec_t
*ri_data
= &iov
;
25 size_t ri_data_len
= 1;
26 __wasi_riflags_t ri_flags
= flags
;
28 // Perform system call.
30 __wasi_roflags_t ro_flags
;
31 __wasi_errno_t error
= __wasi_sock_recv(socket
,
32 ri_data
, ri_data_len
, ri_flags
,