-
Notifications
You must be signed in to change notification settings - Fork 25
Description
I've split this out of #103 as reported by @ivmarkov to keep threads disentangled:
Supporting the
bind_multiplecontract on top ofsmoltcpseems currently impossible, or in the best case would require terrible hacks, assmoltcpdoes seem to assign a source (local) address very late - only when dispatching the UDP packet. The UDP packets in the ring buffer queue however do not have any notion of "source address" before that.So it seems sending with an arbitrary local address would require us to a) wait for the UDP socket ring buffer to become empty (so that we are sure all other pending packets are sent with the "previous" local addr) b) unbind the UDP socket c) rebind the socket with the local address of the packet we want to send (NOTE: this way however we would be missing packets that we want to receive, as the
receive_frompart will now work with the local address that we want to use for sending the packet d) unbind the socket once the packet was sent e) rebind the socket again with the local address as specified inbind_multipleWhat's also weird is that there is quite a bit of asymmetry wrt UDP sockets between
embedded-nalandembedded-nal-async.embedded-nalis pretty simplistic, whileembedded-nal-asyncseems to enforce an API which is too close to the BSD sockets one, and is not necessarily a good fit forsmoltcp. (Not that implementingbind_multipleis particularly easy with STD either.)I'm unsure how to proceed, honestly.
One option would be to just not support
bind_multipleon top ofsmoltcpby having the impl always return an error.Another would be to remove it and/or make it optional in
embedded-nal-async.In any case, not having an impl of the UDP socket traits for
smoltcpis an odd situation to be in, given thatsmoltcpis the one stack used in embedded...@chrysn @lulf @Dirbaio @MabezDev Sorry for pinging. Happy to listen to your feedback / comments / guidance.
Did I miss the elephant in the room?