您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

udp_windows.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. // +build windows
  2. package dns
  3. import "net"
  4. // SessionUDP holds the remote address
  5. type SessionUDP struct {
  6. raddr *net.UDPAddr
  7. }
  8. // RemoteAddr returns the remote network address.
  9. func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr }
  10. // ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a
  11. // net.UDPAddr.
  12. // TODO(fastest963): Once go1.10 is released, use ReadMsgUDP.
  13. func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) {
  14. n, raddr, err := conn.ReadFrom(b)
  15. if err != nil {
  16. return n, nil, err
  17. }
  18. return n, &SessionUDP{raddr.(*net.UDPAddr)}, err
  19. }
  20. // WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr.
  21. // TODO(fastest963): Once go1.10 is released, use WriteMsgUDP.
  22. func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) {
  23. return conn.WriteTo(b, session.raddr)
  24. }
  25. // TODO(fastest963): Once go1.10 is released and we can use *MsgUDP methods
  26. // use the standard method in udp.go for these.
  27. func setUDPSocketOptions(*net.UDPConn) error { return nil }
  28. func parseDstFromOOB([]byte, net.IP) net.IP { return nil }