Conversation
| // 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
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. |
Ungate a number of functions to get UDP send/recv working.