-
Notifications
You must be signed in to change notification settings - Fork 749
Support recvmsg() and sendmsg()
#1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support recvmsg() and sendmsg()
#1042
Conversation
|
@wenyongh what kind of copyright declaration should I add into the example ? |
|
@wenyongh here is the question, the new API
And WAMR socket supporting only covers BTW, the example send_recv.c will be failed in linux: |
c8cf07a to
9fb4430
Compare
Please change AF_INET to AF_LOCAL. |
9fb4430 to
20e7dee
Compare
|
In that case (
Reference: |
|
For the record, we plan to bypass the requirement of |
a77fc63 to
1156129
Compare
| __wasi_iovec_t ri_data = { .buf = msg->msg_iov->iov_base, | ||
| .buf_len = msg->msg_iov->iov_len }; | ||
| size_t ri_data_len = msg->msg_iovlen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should check whether msg is NULL?
- Had better not initialize ri_data with non-const expression
How about:
__wasi_iovec_t ri_data = { 0 };
size_t ri_data_len;
if (!msg) report error;
ri_data.buf = ..;
ri_data.buf_len = ..;
ri_data_len = ..;
| __wasi_ciovec_t si_data = { .buf = msg->msg_iov->iov_base, | ||
| .buf_len = msg->msg_iov->iov_len }; | ||
| size_t si_data_len = msg->msg_iovlen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
1156129 to
31d97cc
Compare
samples/socket-api/README.md
Outdated
| ``` | ||
|
|
||
| `send_recv.wasm` contains a thread as a server and a thread as a client. They | ||
| sends and receives data via 127.0.0.1:1234. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send and receive
samples/socket-api/send_recv.dump
Outdated
| @@ -0,0 +1,16350 @@ | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file?
|
|
||
| if (pthread_cond_init(&cond, NULL)) { | ||
| perror("Initialize condition failed"); | ||
| return EXIT_FAILURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we pthread_mutex_destroy(&lock) before return?
|
|
||
| if (pthread_create(&cs[0], NULL, run_as_server, NULL)) { | ||
| perror("Create a server thread failed"); | ||
| return EXIT_FAILURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, destroy cond and mutex before return?
31d97cc to
041d43f
Compare
041d43f to
d5fd6d6
Compare
Implement socket-api `recvmsg()` and `sendmsg()` for wasm app, add sample and update document.
Add an example, send_recv.c, to test with new socket APIs. Before testing, please uncomment lines in CMakeLists.txt