Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(232)

Delta Between Two Patch Sets: src/pkg/net/sockopt_windows.go

Issue 5562048: code review 5562048: net: ListenMulticastUDP to listen concurrently across m... (Closed)
Left Patch Set: diff -r 23995c78329e https://go.googlecode.com/hg/ Created 12 years, 2 months ago
Right Patch Set: diff -r 48a0594d7375 https://go.googlecode.com/hg/ Created 12 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/sockopt_linux.go ('k') | src/pkg/net/udpsock_plan9.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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.
4
5 // Socket options for Windows
6
7 package net 1 package net
8 2
9 import ( 3 import (
10 "os"
11 "syscall" 4 "syscall"
12 ) 5 )
13 6
14 func setDefaultSockopts(s syscall.Handle, f, t int) error { 7 func setDefaultSockopts(s syscall.Handle, f, t int) {
15 switch f { 8 switch f {
16 case syscall.AF_INET6: 9 case syscall.AF_INET6:
17 // Allow both IP versions even if the OS default is otherwise. 10 // Allow both IP versions even if the OS default is otherwise.
18 » » err := syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IP V6_V6ONLY, 0) 11 » » syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ON LY, 0)
19 » » if err != nil {
20 » » » return os.NewSyscallError("setsockopt", err)
21 » » }
22
23 } 12 }
24 13
25 // Windows will reuse recently-used addresses by default.
26 // SO_REUSEADDR should not be used here, as it allows
27 // a socket to forcibly bind to a port in use by another socket.
28 // This could lead to a non-deterministic behavior, where
29 // connection requests over the port cannot be guaranteed
30 // to be handled by the correct socket.
31
32 // Allow broadcast.
33 err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST , 1)
34 if err != nil {
35 return os.NewSyscallError("setsockopt", err)
36 }
37
38 return nil
39 }
40
41 func setDefaultMulticastSockopts(s syscall.Handle) error {
42 // Allow multicast UDP and raw IP datagram sockets to listen
43 // concurrently across multiple listeners.
44 err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR , 1)
45 if err != nil {
46 return os.NewSyscallError("setsockopt", err)
47 }
48 return nil
49 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b