OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
| 5 // +build darwin freebsd |
| 6 |
5 // Sockets for BSD variants | 7 // Sockets for BSD variants |
6 | 8 |
7 package net | 9 package net |
8 | 10 |
9 import ( | 11 import ( |
10 "syscall" | 12 "syscall" |
11 ) | 13 ) |
12 | 14 |
13 func setKernelSpecificSockopt(s, f int) { | 15 func setKernelSpecificSockopt(s, f int) { |
14 // Allow reuse of recently-used addresses. | 16 // Allow reuse of recently-used addresses. |
15 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) | 17 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) |
16 | 18 |
17 // Allow reuse of recently-used ports. | 19 // Allow reuse of recently-used ports. |
18 // This option is supported only in descendants of 4.4BSD, | 20 // This option is supported only in descendants of 4.4BSD, |
19 // to make an effective multicast application and an application | 21 // to make an effective multicast application and an application |
20 // that requires quick draw possible. | 22 // that requires quick draw possible. |
21 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1) | 23 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1) |
22 | 24 |
23 // Allow broadcast. | 25 // Allow broadcast. |
24 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1) | 26 syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1) |
25 | 27 |
26 if f == syscall.AF_INET6 { | 28 if f == syscall.AF_INET6 { |
27 // using ip, tcp, udp, etc. | 29 // using ip, tcp, udp, etc. |
28 // allow both protocols even if the OS default is otherwise. | 30 // allow both protocols even if the OS default is otherwise. |
29 syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ON
LY, 0) | 31 syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ON
LY, 0) |
30 } | 32 } |
31 } | 33 } |
OLD | NEW |