aboutsummaryrefslogtreecommitdiff
path: root/src/net/udpsock.go
AgeCommit message (Collapse)Author
2025-10-29internal/itoa, internal/runtime/strconv: deleteRuss Cox
Replaced by internal/strconv. Change-Id: I0656a9ad5075e60339e963fbae7d194d2f3e16be Reviewed-on: https://go-review.googlesource.com/c/go/+/716001 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-08-11net: context aware Dialer.Dial functionsMichael Fraenkel
Add context aware dial functions for TCP, UDP, IP and Unix networks. Fixes #49097 Updates #59897 Change-Id: I7523452e8e463a587a852e0555cec822d8dcb3dd Reviewed-on: https://go-review.googlesource.com/c/go/+/490975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
2025-06-12net: remove some BUG entriesCherry Mui
A few methods that were not implemented on Windows are implemented in CL 668195. Change-Id: I35423792a5af00f29fcd24e56a6dfcf013669371 Reviewed-on: https://go-review.googlesource.com/c/go/+/680180 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-07-22net: add godoc links on UDP related symbolsOlivier Mengué
Change-Id: Ibc861e7b2aebc8fd1e0ba15d8d35ae0ecfe7747e Reviewed-on: https://go-review.googlesource.com/c/go/+/599996 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-07-20net: remove unused error result from newRawConnDaniel Martí
It's currently always nil, and the code gets generally less verbose. Change-Id: Id4f5f9ac6eac0218dda34b8bd5ef41c633cfaf2d Reviewed-on: https://go-review.googlesource.com/c/go/+/508396 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-07-27net: document UDPConn.ReadFromUDPAddrPort's AddrPort result moreBrad Fitzpatrick
Clarify the form of its IPv4 addresses when listening on an unspecified address. (found while testing/reviewing CL 399454) Change-Id: I62b367f5a4e6d340eb72dd7ec342080f1821e63e Reviewed-on: https://go-review.googlesource.com/c/go/+/419614 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2021-11-10net: do more faithful conversion from AddrPort to UDPAddrJason A. Donenfeld
A UDPAddr with a nil IP is a valid state, representing an AF-agnostic unspecified address, so checking for addr.IsValid() isn't correct; remove that, as it's only needed in the UDP rx path where it can be added. Secondly, forcing everything to be IPv6 also is not correct, and was likely done when the missing .AsSlice() made doing the right thing less ergonomic. Fix this by using .AsSlice(), which properly preserves IP version. Change-Id: Idd1eaecd4076f32a843f859a0a9802ef98f956d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/361478 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-11-02net: add ReadFromUDPAddrPortJosh Bleecher Snyder
It is now possible to do completely allocation-free UDP. This is implemented completely separately from ReadFromUDP because ReadFromUDP exists in a delicate balance to allow mid-stack inlining. After performance-sensitive callers have migrated to ReadFromUDPAddrPort, we may be able to simplify ReadFromUDP to call ReadFromUDPAddrPort. name old time/op new time/op delta WriteToReadFromUDPAddrPort-8 4.71µs ± 2% 4.81µs ± 5% +2.18% (p=0.000 n=14+14) name old alloc/op new alloc/op delta WriteToReadFromUDPAddrPort-8 4.00B ± 0% 0.00B -100.00% (p=0.000 n=15+15) name old allocs/op new allocs/op delta WriteToReadFromUDPAddrPort-8 1.00 ± 0% 0.00 -100.00% (p=0.000 n=15+15) Change-Id: I37f5ad9416a1d4333ed48d83474b2cf933b2a1be Reviewed-on: https://go-review.googlesource.com/c/go/+/360600 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02net: optimize WriteToUDPAddrPortJosh Bleecher Snyder
See the recent change optimizing WriteMsgUDPAddrPort for an explanation of why this change includes copy/paste/modify instead of implementing WriteToUDP using WriteToUDPAddrPort. name old time/op new time/op delta WriteToReadFromUDPAddrPort-8 5.02µs ± 3% 4.71µs ± 2% -6.31% (p=0.000 n=15+14) name old alloc/op new alloc/op delta WriteToReadFromUDPAddrPort-8 68.0B ± 0% 4.0B ± 0% -94.12% (p=0.000 n=15+15) name old allocs/op new allocs/op delta WriteToReadFromUDPAddrPort-8 3.00 ± 0% 1.00 ± 0% -66.67% (p=0.000 n=15+15) Change-Id: I301715e774de07eb6ccb4e329ccf2e554609abc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/360599 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02net: optimize WriteMsgUDPAddrPortJosh Bleecher Snyder
This is one step towards optimizing WriteMsgUDPAddrPort. Further steps remain, namely to avoid the syscall.Sockaddr interface, as we do for UDPConn.WriteToUDP and UDPConn.ReadFromUDP. A previous change optimized ReadMsgUDPAddrPort by having ReadMsgUDP call ReadMsgUDPAddrPort rather than the other way around. This change does not implement WriteMsgUDP in terms of WriteMsgUDPAddrPort, because a few layers deep, on posix platforms only (in ipToSockaddrInet4 and ipToSockaddrInet6), is special handling of zero-length IP addresses and IPv4zero. It treats IP(nil) as equivalent to 0.0.0.0 or ::, and 0.0.0.0 as equivalent to :: in an IPv6 context. Based on the comments, I suspect that this treatment was intended for the Listen* API, not the Write* API, but it affects both, and I am nervous about changing the behavior for Write*. The netip package doesn't have a way to represent a "zero-length IP address" as distinct from an invalid IP address (which is a good thing), so to implement WriteMsgUDP using WriteMsgUDPAddrPort, we would have to duplicate this special handling at the start of WriteMsgUDP. But this handling depends on whether the UDPConn is an IPv4 or an IPv6 conn, which is also platform-specific information. As a result, every attempt I made to implement WriteMsgUDP using WriteMsgUDPAddrPort while preserving behavior ended up being considerably worse than copy/paste/modify. This does mean that WriteMsgUDP and WriteMsgUDPAddrPort will have different behavior in these cases. name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 5.29µs ± 6% 5.02µs ± 7% -5.14% (p=0.000 n=13+15) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 128B ± 0% 64B ± 0% -50.00% (p=0.000 n=15+15) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 4.00 ± 0% 2.00 ± 0% -50.00% (p=0.000 n=15+15) Change-Id: Ia78eb49734f4301d7772dfdbb5a87e4d303a9f7a Reviewed-on: https://go-review.googlesource.com/c/go/+/360597 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02net: optimize ReadMsgUDPAddrPortJosh Bleecher Snyder
Instead of implementing ReadMsgUDPAddrPort in terms of ReadMsgUDP, do it the other way around. This keeps the code minimal while still avoiding allocs. We could also rearrange ReadMsgUDP to be mid-stack inlined to avoid allocating the *UDPAddr, but anyone who's trying to eliminate allocs should use ReadMsgUDPAddrPort instead anyway, because ReadMsgUDP will always allocate at least once (the IP slice). name old time/op new time/op delta ReadWriteMsgUDPAddrPort-8 5.26µs ± 3% 5.29µs ± 6% ~ (p=0.429 n=12+13) name old alloc/op new alloc/op delta ReadWriteMsgUDPAddrPort-8 176B ± 0% 128B ± 0% -27.27% (p=0.000 n=15+15) name old allocs/op new allocs/op delta ReadWriteMsgUDPAddrPort-8 5.00 ± 0% 4.00 ± 0% -20.00% (p=0.000 n=15+15) Change-Id: I15228cb4ec4f13f2f390407b6c62c44c228e7201 Reviewed-on: https://go-review.googlesource.com/c/go/+/360596 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02net/netip: add new IP address packageBrad Fitzpatrick
Co-authored-by: Alex Willmer <alex@moreati.org.uk> (GitHub @moreati) Co-authored-by: Alexander Yastrebov <yastrebov.alex@gmail.com> Co-authored-by: David Anderson <dave@natulte.net> (Tailscale CLA) Co-authored-by: David Crawshaw <crawshaw@tailscale.com> (Tailscale CLA) Co-authored-by: Dmytro Shynkevych <dmytro@tailscale.com> (Tailscale CLA) Co-authored-by: Elias Naur <mail@eliasnaur.com> Co-authored-by: Joe Tsai <joetsai@digital-static.net> (Tailscale CLA) Co-authored-by: Jonathan Yu <jawnsy@cpan.org> (GitHub @jawnsy) Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com> (Tailscale CLA) Co-authored-by: Maisem Ali <maisem@tailscale.com> (Tailscale CLA) Co-authored-by: Manuel Mendez (Go AUTHORS mmendez534@...) Co-authored-by: Matt Layher <mdlayher@gmail.com> Co-authored-by: Noah Treuhaft <noah.treuhaft@gmail.com> (GitHub @nwt) Co-authored-by: Stefan Majer <stefan.majer@gmail.com> Co-authored-by: Terin Stock <terinjokes@gmail.com> (Cloudflare CLA) Co-authored-by: Tobias Klauser <tklauser@distanz.ch> Fixes #46518 Change-Id: I0041f9e1115d61fa6e95fcf32b01d9faee708712 Reviewed-on: https://go-review.googlesource.com/c/go/+/339309 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-03-15net: use mid-stack inlining with ReadFromUDP to avoid an allocationJosh Bleecher Snyder
This commit rewrites ReadFromUDP to be mid-stack inlined and pass a UDPAddr for lower layers to fill in. This lets performance-sensitive clients avoid an allocation. It requires some care on their part to prevent the UDPAddr from escaping, but it is now possible. The UDPAddr trivially does not escape in the benchmark, as it is immediately discarded. name old time/op new time/op delta WriteToReadFromUDP-8 17.2µs ± 6% 17.1µs ± 5% ~ (p=0.387 n=9+9) name old alloc/op new alloc/op delta WriteToReadFromUDP-8 112B ± 0% 64B ± 0% -42.86% (p=0.000 n=10+10) name old allocs/op new allocs/op delta WriteToReadFromUDP-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=10+10) Updates #43451 Co-authored-by: Filippo Valsorda <filippo@golang.org> Change-Id: I1f9d2ab66bd7e4eff07fe39000cfa0b45717bd13 Reviewed-on: https://go-review.googlesource.com/c/go/+/291509 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Trust: Filippo Valsorda <filippo@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Trust: Jason A. Donenfeld <Jason@zx2c4.com>
2021-03-14all: add internal/itoa packageJosh Bleecher Snyder
This replaces five implementations scattered across low level packages. (And I plan to use it in a sixth soon.) Three of the five were byte-for-byte identical. Change-Id: I3bbbeeac63723a487986c912b604e10ad1e042f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/301549 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2020-11-30net: add note about disabling loopback in ListenMulticastUDP()Andy Pan
Fixes #41752 Change-Id: I83520d2303e5fd2e5f6329f092b40e73c13771a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/271908 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2019-10-09all: remove the nacl port (part 1)Brad Fitzpatrick
You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-03net: update docs for unimplemented methods and functionsMikio Hara
Change-Id: I54e651a952afa8928cc0204ba37092d3b2347266 Reviewed-on: https://go-review.googlesource.com/127737 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-29net: move dial and listen functions under sysDialer, sysListenerAudrius Butkevicius
Updates #9661 Change-Id: I237e7502cb9faad6dece1e25b1a503739c54d826 Reviewed-on: https://go-review.googlesource.com/115175 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-10net: implement ReadMsg/WriteMsg on windowsAman Gupta
This means {Read,Write}Msg{UDP,IP} now work on windows. Fixes #9252 Change-Id: Ifb105f9ad18d61289b22d7358a95faabe73d2d02 Reviewed-on: https://go-review.googlesource.com/76393 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-07-06net: don't return IPv4 unspecified addr for Resolve*Addr of [::] or [::]:nBrad Fitzpatrick
ResolveTCPAddr, ResolveUDPAddr, and ResolveIPAddr return at most one address. When given a name like "golang.org" to resolve that might have more than 1 address, the net package has historically preferred IPv4 addresses, with the assumption that many users don't yet have IPv6 connectivity and randomly selecting between an IPv4 address and an IPv6 address at runtime wouldn't be a good experience for IPv4-only users. In CL 45088 (78cf0e56) I modified the resolution of the unspecified/empty address to internally resolve to both IPv6 "::" and 0.0.0.0 to fix issue #18806. That code has 3 other callers I hadn't considered, though: the Resolve*Addr functions. Since they preferred IPv4, any Resolve*Addr of "[::]:port" or "::" (for ResolveIPAddr) would internally resolve both "::" and 0.0.0.0 and then prefer 0.0.0.0, even though the user was looking up an IPv6 literal. Add tests and fix it, not by undoing the fix to #18806 but by selecting the preference function for Resolve*Addr more explicitly: we still prefer IPv4, but if the address being looked up was an IPv6 literal, prefer IPv6. The tests are skipped on machines without IPv6. Fixes #20911 Change-Id: Ib7036cc43182ae4118cd1390c254e17c04a251a3 Reviewed-on: https://go-review.googlesource.com/47554 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2017-06-22net: update documentation on methods of UDPConnMikio Hara
This change simplifies the documentation on methods of UDPConn and adds a reference to golang.org/x/net/{ipv4,ipv6} packages to the documentation on {Read,Write}MsgUDP methods. Change-Id: I425a8d81bc46b6579aa9f89faa4982bb86b40f24 Reviewed-on: https://go-review.googlesource.com/44912 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-22net: update documentation on Resolve{TCP,UDP,IP,Unix}AddrMikio Hara
This change clarifies the documentation on Resolve{TCP,UDP,IP,Unix}Addr to avoid unnecessary confusion about how the arguments are used to make end point addresses. Also replaces "name" or "hostname" with "host name" when the term implies the use of DNS. Updates #17613. Change-Id: Id6be87fe2e4666eecd5b92f18ad8b9a6c50a2bd6 Reviewed-on: https://go-review.googlesource.com/34879 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-22net: update documentation on Listen{TCP,UDP,MulticastUDP,IP,Unix,Unixgram}Mikio Hara
This change clarifies the documentation on Listen{TCP,UDP,MulticastUDP,IP,Unix,Unixgram} to avoid unnecessary confusion about how the arguments for the connection setup functions are used to make connections. Change-Id: Ie269453ef49ec2db893391dc3ed2f7b641c14249 Reviewed-on: https://go-review.googlesource.com/34878 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-22net: update documentation on Dial{TCP,UDP,IP,Unix}Mikio Hara
This change clarifies the documentation on Dial{TCP,UDP,IP,Unix} to avoid unnecessary confusion about how the arguments for the connection setup functions are used to make connections. Change-Id: I2e378182948fbe221f6ae786ab55e77ae90c3f3b Reviewed-on: https://go-review.googlesource.com/34877 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-19net: make {TCP,UDP,IP,Unix}Conn compliant of syscall.Conn interfaceMikio Hara
This change makes {TCP,UDP,IP,Unix}Conn types compliant of syscall.Conn interface and adds type rawConn as an implementation of syscall.RawConn interface. By this change, the long-standing issues regarding unsupported socket options and system calls can be solved partly and the broken x/net packages due to https://go-review.googlesource.com/36799 can be repaired. Fixes #3661. Updates #9661. Updates #19051. Updates #19435. Change-Id: Ic996b040418b54f6d043bc70591789d5a5b23270 Reviewed-on: https://go-review.googlesource.com/37039 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-28net: add missing comma on BUGS section for consistencyMikio Hara
Change-Id: Ic96fb52f37257e06e77cc08da5c73ea6f9ff158c Reviewed-on: https://go-review.googlesource.com/33592 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-27net: add multicast UDP support for plan9Chris McGee
The new implementation adds listening support on a multicast address with plan9 network interfaces. Fixes #17218 Change-Id: I2c75515e72e120acb71610cd077fddfbf9cf4e29 Reviewed-on: https://go-review.googlesource.com/29964 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-25net: add hostname warnings to all first(isIPv4) functions.Paul Marks
In general, these functions cannot behave correctly when given a hostname, because a hostname may represent multiple IP addresses, and first(isIPv4) chooses at most one. Updates #9334 Change-Id: Icfb629f84af4d976476385a3071270253c0000b1 Reviewed-on: https://go-review.googlesource.com/31931 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-21net: add Resolver type, Dialer.Resolver, and DefaultResolverBrad Fitzpatrick
The new Resolver type (a struct) has 9 Lookup methods, all taking a context.Context. There's now a new DefaultResolver global, like http's DefaultTransport and DefaultClient. net.Dialer now has an optional Resolver field to set the Resolver. This also does finishes some resolver cleanup internally, deleting lookupIPMerge and renaming lookupIPContext into Resolver.LookupIPAddr. The Resolver currently doesn't let you tweak much, but it's a struct specifically so we can add knobs in the future. Currently I just added a bool to force the pure Go resolver. In the future we could let people provide an interface to implement the methods, or add a Timeout time.Duration, which would wrap all provided contexts in a context.WithTimeout. Fixes #16672 Change-Id: I7ba1f886704f06def7b6b5c4da9809db51bc1495 Reviewed-on: https://go-review.googlesource.com/29440 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-23net: document unimplemented methods and functionsMikio Hara
Fixes #16802. Change-Id: I41be7bb4e21e3beaa2136ee69771b0f455b2a7c6 Reviewed-on: https://go-review.googlesource.com/27417 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-15net: context plumbing, add Dialer.DialContextBrad Fitzpatrick
For #12580 (http.Transport tracing/analytics) Updates #13021 Change-Id: I126e494a7bd872e42c388ecb58499ecbf0f014cc Reviewed-on: https://go-review.googlesource.com/22101 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-03-16net: deduplicate UDP socket codeMikio Hara
This change consolidates functions and methods related to UDPAddr and UDPConn for maintenance purpose, especially for documentation. The followup changes will update comments and examples. Updates #10624. Change-Id: Idfe9be8ea46ade1111b0ae176862b2048eafc7be Reviewed-on: https://go-review.googlesource.com/20120 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-13net: don't return non-nil interface values as Source, Addr in OpErrorMikio Hara
Fixes #10992. Change-Id: Ia376e4de118993b43e5813da57ab25fea8122048 Reviewed-on: https://go-review.googlesource.com/10476 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-10net: make multi-IP resolution more flexible.Paul Marks
Remove the "netaddr" type, which ambiguously represented either one address, or a list of addresses. Instead, use "addrList" wherever multiple addresses are supported. The "first" method returns the first address matching some condition (e.g. "is it IPv4?"), primarily to support legacy code that can't handle multiple addresses. The "partition" method splits an addrList into two categories, as defined by some strategy function. This is useful for implementing Happy Eyeballs, and similar two-channel algorithms. Finally, internetAddrList (formerly resolveInternetAddr) no longer mangles the ordering defined by getaddrinfo. In the future, this may be used by a sequential Dial implementation. Updates #8453, #8455. Change-Id: I7375f4c34481580ab40e31d33002a4073a0474f3 Reviewed-on: https://go-review.googlesource.com/8360 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-03-28net: simplify test helpersMikio Hara
This change consolidates test helpers that test platform capabilities. testNetwork, testAddress and testListenArgs report whether given ariguments are testable on the current platform configuration to mitigate to receive weird test results. Change-Id: Ie1ed568a1f9cc50f3155945ea01562904bc2c389 Reviewed-on: https://go-review.googlesource.com/8076 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.