-
Notifications
You must be signed in to change notification settings - Fork 2k
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
gnrc_sock_udp: add sendto #6196
Conversation
- extend api with new call sock_udp_sendto - does not break existing API - adapt sock_udp_send, refine error handling
Could you elaborate on why you think having another sendto call improves the API? Are you aware of the discussion in #5758? |
As said above, the original send function tries to handle all possible cases with an abundance of Introducing a Regarding #5758: was there a discussion on |
That looks more like a bug in the |
A connected connectionless transport? |
#6203 offers a less intrusive fix for the error reported by the static code analyzer. |
@OlegHahm, maybe I should've put that in italics or something, however, isn't that how they call these in the BSD/POSIX socket API? You can run @miri64 for this PR However, if I understood you correctly in #5758, you are argued in favor of a user/developer friendly API instead of aligning the API to the network stack; Regarding #6203, my point here was not about providing a (minimal intrusive) fix by adding/checking another condition, but arguing in favor of a API semantics. |
For this the PR changes a lot... Don't get me wrong, if you see a benefit in e.g. constraining the port range for an unbound sock, I happily take it in a separate PR, but I don't see any benefit in splitting up the funtcion and making the API more complicated.
A very simple reason: you can use it as Speaking of: how does it fit into your API proposal? And how does
See, this is where I'm massively confused, because the semantics of your int sendto(s, buf, remote);
static inline int send(s, buf)
{
return sendto(s, buf, NULL);
} If my implementation of the API for GNRC is the problem, we also could implement a "sendto" there and have it called when After all the problem is: A change to |
@miri64: ah, I forgot about the port range stuff I added here as well. The idea behind this was to eliminate the need to call random and specify an allowed port range, excluding possible collisions, e.g., with typically, reserved system ports < 1000. Leaving |
Wait a second: do I understand it correctly that the current implementation does not chose the source port from the ephemeral ports? If the answer is yes, then this should clearly be changed in a separate PR. |
I don't see the extra function as an API enhancement.
To which network stack? The network stack side has to be used once for every stack, the application side has to be used once per application. So maybe currently the ease of use is on the wrong side, but that will change as soon as there's a second application actually utilizing sock.
What is unclear about sock's current UDP send() semantics? Why is "sendto" clearer, more user friendly? |
@kaspar030: its my personal, subjective opinion that a However, as suggested here (and I think @OlegHahm agrees) the source port handling should be changed. I'll prepare a PR for that, and we may close this one afterwards ... |
*the source port handling for GNRC. ;-) |
This PR started with the following error when calling
make scan-build-analyze
:Trying to resolve this issue I thought it might be nice to have an explicit
sock_udp_sendto
call,thenthan the rather complicated checking insock_udp_send
. This PR adds such function without breaking API and existing applications using it.However, if approved I would like to remove the
remote
parameter fromsock_udp_send
and adapt applications to usesendto
where required instead. Which meanssock_udp_send
would only be used for connected UDP socks andsendto
otherwise.