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
2 changes: 1 addition & 1 deletion samples/socket-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Client is running...
Start receiving.
Start sending.
Send 106 bytes successfully!
Receive 106 bytes successlly!
Receive 106 bytes successfully!
Data:
The stars shine down
It brings us light
Expand Down
10 changes: 7 additions & 3 deletions samples/socket-api/wasm-src/send_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static bool server_is_ready = false;
void *
run_as_server(void *arg)
{
(void)arg;
int sock = -1, on = 1;
struct sockaddr_in addr = { 0 };
int addrlen = 0;
Expand Down Expand Up @@ -109,14 +110,15 @@ run_as_server(void *arg)
fail2:
close(new_sock);
fail1:
shutdown(sock, SHUT_RD);
shutdown(sock, SHUT_RDWR);
close(sock);
return NULL;
}

void *
run_as_client(void *arg)
{
(void)arg;
int sock = -1;
struct sockaddr_in addr = { 0 };
/* buf of server is 106 bytes */
Expand Down Expand Up @@ -159,7 +161,7 @@ run_as_client(void *arg)
goto fail;
}

printf("Receive %ld bytes successlly!\n", recv_len);
printf("Receive %ld bytes successfully!\n", recv_len);
assert(recv_len == 106);

printf("Data:\n");
Expand All @@ -170,14 +172,16 @@ run_as_client(void *arg)
}

fail:
shutdown(sock, SHUT_RD);
shutdown(sock, SHUT_RDWR);
close(sock);
return NULL;
}

int
main(int argc, char *argv[])
{
(void)argc;
(void)argv;
pthread_t cs[2] = { 0 };
uint8_t i = 0;
int ret = EXIT_SUCCESS;
Expand Down
10 changes: 7 additions & 3 deletions samples/wasm-c-api-imports/wasm/send_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ local_printf(const char *formatter, ...)
void *
run_as_server(void *arg)
{
(void)arg;
int sock = -1, on = 1;
struct sockaddr_in addr = { 0 };
int addrlen = 0;
Expand Down Expand Up @@ -134,14 +135,15 @@ run_as_server(void *arg)
fail2:
close(new_sock);
fail1:
shutdown(sock, SHUT_RD);
shutdown(sock, SHUT_RDWR);
close(sock);
return NULL;
}

void *
run_as_client(void *arg)
{
(void)arg;
int sock = -1;
struct sockaddr_in addr = { 0 };
/* buf of server is 106 bytes */
Expand Down Expand Up @@ -184,7 +186,7 @@ run_as_client(void *arg)
goto fail;
}

local_printf("Receive %ld bytes successlly!\n", recv_len);
local_printf("Receive %ld bytes successfully!\n", recv_len);
assert(recv_len == 106);

local_printf("Data:\n");
Expand All @@ -195,14 +197,16 @@ run_as_client(void *arg)
}

fail:
shutdown(sock, SHUT_RD);
shutdown(sock, SHUT_RDWR);
close(sock);
return NULL;
}

int
main(int argc, char *argv[])
{
(void)argc;
(void)argv;
pthread_t cs[2] = { 0 };
uint8_t i = 0;
int ret = EXIT_SUCCESS;
Expand Down
Loading