Add timeout send/recv and multicast client/server socket examples (#1519)
Add a couple of socket examples that can be used with WAMR: - The `timeout_client` and `timeout_server` examples demonstrate socket send and receive timeouts using the socket options - The `multicast_client` and `multicast_server` examples demonstrate receiving multicast packets in WASM And add several macro controls for `socket_opts` example.
This commit is contained in:
@ -692,12 +692,12 @@ get_ipproto_ip_option(int sockfd, int optname, void *__restrict optval,
|
||||
HANDLE_ERROR(error);
|
||||
return error;
|
||||
case IP_TTL:
|
||||
assert(*optlen == sizeof(uint8_t));
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_ip_ttl(sockfd, (uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return error;
|
||||
case IP_MULTICAST_TTL:
|
||||
assert(*optlen == sizeof(uint8_t));
|
||||
assert(*optlen == sizeof(int));
|
||||
error = __wasi_sock_get_ip_multicast_ttl(sockfd, (uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return error;
|
||||
@ -915,12 +915,12 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
|
||||
HANDLE_ERROR(error);
|
||||
return error;
|
||||
case IP_TTL:
|
||||
assert(optlen == sizeof(uint8_t));
|
||||
assert(optlen == sizeof(int));
|
||||
error = __wasi_sock_set_ip_ttl(sockfd, *(uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
return error;
|
||||
case IP_MULTICAST_TTL:
|
||||
assert(optlen == sizeof(uint8_t));
|
||||
assert(optlen == sizeof(int));
|
||||
error =
|
||||
__wasi_sock_set_ip_multicast_ttl(sockfd, *(uint8_t *)optval);
|
||||
HANDLE_ERROR(error);
|
||||
|
||||
Reference in New Issue
Block a user