1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Socket options for Linux
13 func setDefaultSockopts(s, f, p int) {
15 case syscall.AF_INET6:
16 // Allow both IP versions even if the OS default is otherwise.
17 syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 0)
20 if f == syscall.AF_UNIX || p == syscall.IPPROTO_TCP {
21 // Allow reuse of recently-used addresses.
22 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
26 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
30 func setDefaultMulticastSockopts(fd *netFD) {
33 // Allow multicast UDP and raw IP datagram sockets to listen
34 // concurrently across multiple listeners.
35 syscall.SetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)