net/udpsock: exposes contexts for several UDP related functions:
In the udpsock package are several (exposed) functions (see below) which use context.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 context ctx). 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 the WithContext functions and call them with context.Background().
net/udpsock: exposes contexts for several UDP related functions:
In the
udpsockpackage are several (exposed) functions (see below) which usecontext.Background()as context for calls to unexposed internal functions.ResolveUDPAddrDialUDPListenUDPListenMulticastUDPI 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
WithContextand an additional argument (namely the contextctx). This would add the following functions:ResolveUDPAddrWithContextDialUDPWithContextListenUDPWithContextListenMulticastUDPWithContextWith the same signature but a
context.Conteextadded as first argument. Internally the "non-context" function from above, are then just wrappers for theWithContextfunctions and call them withcontext.Background().