Skip to content

proposal: net: context variants for udp functions #59897

@milkpirate

Description

@milkpirate

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions