Skip to content

wasip3: Implement UDP#763

Merged
alexcrichton merged 1 commit intoWebAssembly:mainfrom
alexcrichton:wasip3-udp
Mar 5, 2026
Merged

wasip3: Implement UDP#763
alexcrichton merged 1 commit intoWebAssembly:mainfrom
alexcrichton:wasip3-udp

Conversation

@alexcrichton
Copy link
Copy Markdown
Collaborator

Ungate a number of functions to get UDP send/recv working.

@alexcrichton alexcrichton requested a review from dicej March 5, 2026 01:09
// Copy out the datagram to the caller.
size_t datagram_size = result.val.ok.f0.len;
size_t bytes_to_copy = datagram_size < length ? datagram_size : length;
memcpy(buffer, result.val.ok.f0.ptr, bytes_to_copy);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought for later (does not need to be addressed now): I'm wondering if we could avoid the copy by using the buffer directly, given that we're either blocking or cancelling if the read would block, meaning the buffer need not be valid once we return from this function. (This presumably applies to TCP reads also). Am I missing something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given today's canonical ABI I don't think we can do that, right? The WIT itself returns list<u8> which we wouldn't be able to integrate with the caller's buffer?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. I had glossed over that udp-socket.receive returns a list<u8> rather than a stream<u8> like in tcp-socket. Yeah, I guess we'd either need to change the WIT or wait for lazy lowering.

Ungate a number of functions to get UDP send/recv working.
@alexcrichton alexcrichton enabled auto-merge (squash) March 5, 2026 20:48
@alexcrichton
Copy link
Copy Markdown
Collaborator Author

I'm going to go ahead and flag this for merge, but @dicej if you have thoughts/concerns on follow-ups to #763 (comment) I'm happy to do a follow-up PR here too.

@dicej
Copy link
Copy Markdown
Collaborator

dicej commented Mar 5, 2026

I'm going to go ahead and flag this for merge, but @dicej if you have thoughts/concerns on follow-ups to #763 (comment) I'm happy to do a follow-up PR here too.

Sorry, I responded, but the response didn't get posted because it was attached to a review I never submitted. Anyway, fine to merge.

@alexcrichton alexcrichton merged commit 08be569 into WebAssembly:main Mar 5, 2026
29 checks passed
@alexcrichton alexcrichton deleted the wasip3-udp branch March 6, 2026 04:03
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

Successfully merging this pull request may close these issues.

2 participants