mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Try to SO_REUSEADDR on Windows
This commit is contained in:
		
							parent
							
								
									eae8f9a666
								
							
						
					
					
						commit
						ae48a1721e
					
				
					 2 changed files with 23 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
// +build !linux,!darwin,!netbsd,!freebsd,!openbsd,!dragonflybsd
 | 
			
		||||
// +build !linux,!darwin,!netbsd,!freebsd,!openbsd,!dragonflybsd,!windows
 | 
			
		||||
 | 
			
		||||
package yggdrasil
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										22
									
								
								src/yggdrasil/multicast_windows.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/yggdrasil/multicast_windows.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
// +build windows
 | 
			
		||||
 | 
			
		||||
package yggdrasil
 | 
			
		||||
 | 
			
		||||
import "syscall"
 | 
			
		||||
import "golang.org/x/sys/windows"
 | 
			
		||||
 | 
			
		||||
func multicastReuse(network string, address string, c syscall.RawConn) error {
 | 
			
		||||
	var control error
 | 
			
		||||
	var reuseaddr error
 | 
			
		||||
 | 
			
		||||
	control = c.Control(func(fd uintptr) {
 | 
			
		||||
		reuseaddr = windows.SetsockoptInt(windows.Handle(fd), windows.SOL_SOCKET, windows.SO_REUSEADDR, 1)
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	switch {
 | 
			
		||||
	case reuseaddr != nil:
 | 
			
		||||
		return reuseaddr
 | 
			
		||||
	default:
 | 
			
		||||
		return control
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue