Skip to content
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 WASIp2 sockets in read and write #521

Open
dicej opened this issue Jul 29, 2024 · 0 comments
Open

Support WASIp2 sockets in read and write #521

dicej opened this issue Jul 29, 2024 · 0 comments

Comments

@dicej
Copy link
Contributor

dicej commented Jul 29, 2024

Currently, you can use recv and send to read from and write to WASIp2 sockets, respectively, but neither read nor write work. We should support those functions as well, using logic analogous to what we have in close, where we check whether the file descriptor is a WASIp2 socket and defer to the appropriate function if it is:

#ifdef __wasilibc_use_wasip2
descriptor_table_entry_t entry;
if (descriptor_table_remove(fd, &entry)) {
switch (entry.tag)
{
case DESCRIPTOR_TABLE_ENTRY_TCP_SOCKET:
drop_tcp_socket(entry.tcp_socket);
break;
case DESCRIPTOR_TABLE_ENTRY_UDP_SOCKET:
drop_udp_socket(entry.udp_socket);
break;
default: /* unreachable */ abort();
}
return 0;
}
#endif // __wasilibc_use_wasip2

(Note that whereas we use descriptor_table_remove in the close implementation, we'll want to use descriptor_table_get_ref in the read and write implementations.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant