udp_windows.go (1066B)
1 //go:build windows 2 // +build windows 3 4 // TODO(tmthrgd): Remove this Windows-specific code if go.dev/issue/7175 and 5 // go.dev/issue/7174 are ever fixed. 6 7 package dns 8 9 import "net" 10 11 // SessionUDP holds the remote address 12 type SessionUDP struct { 13 raddr *net.UDPAddr 14 } 15 16 // RemoteAddr returns the remote network address. 17 func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } 18 19 // ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a 20 // net.UDPAddr. 21 func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { 22 n, raddr, err := conn.ReadFrom(b) 23 if err != nil { 24 return n, nil, err 25 } 26 return n, &SessionUDP{raddr.(*net.UDPAddr)}, err 27 } 28 29 // WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr. 30 func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { 31 return conn.WriteTo(b, session.raddr) 32 } 33 34 func setUDPSocketOptions(*net.UDPConn) error { return nil } 35 func parseDstFromOOB([]byte, net.IP) net.IP { return nil }