-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: net: context variants for udp functions #59897
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
Comments
This is largely a dup of #49097, which is a proposal that has been accepted but not yet implemented. |
Change https://go.dev/cl/490975 mentions this issue: |
@ianlancetaylor And to be honest, I like my version better (who would have seen that comming?😄), since its:
How do we go forward? Shall I adapt my PR to make context available to other methods/functions in https://go.dev/cl/490975 ? |
net/udpsock: exposes contexts for several UDP related functions:
In the
udpsock
package are several (exposed) functions (see below) which usecontext.Background()
as context for calls to unexposed internal functions.ResolveUDPAddr
DialUDP
ListenUDP
ListenMulticastUDP
I propose to expose the contexts to the user. See PR #59880. This makes it possible for the user to hand over its own context and allows hin/her to e.g. cancel or timeout the named UDP actions.
The PR does not change the API for the existing functions above, it just adds another function for each of them with the suffix
WithContext
and an additional argument (namely the contextctx
). This would add the following functions:ResolveUDPAddrWithContext
DialUDPWithContext
ListenUDPWithContext
ListenMulticastUDPWithContext
With the same signature but a
context.Conteext
added as first argument. Internally the "non-context" function from above, are then just wrappers for theWithContext
functions and call them withcontext.Background()
.The text was updated successfully, but these errors were encountered: