sockaddr_posix.go 996 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2018 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. //go:build aix || darwin || dragonfly || freebsd || hurd || (js && wasm) || linux || netbsd || openbsd || solaris || windows
  5. package net
  6. import (
  7. "syscall"
  8. )
  9. // A sockaddr represents a TCP, UDP, IP or Unix network endpoint
  10. // address that can be converted into a syscall.Sockaddr.
  11. type sockaddr interface {
  12. Addr
  13. // family returns the platform-dependent address family
  14. // identifier.
  15. family() int
  16. // isWildcard reports whether the address is a wildcard
  17. // address.
  18. isWildcard() bool
  19. // sockaddr returns the address converted into a syscall
  20. // sockaddr type that implements syscall.Sockaddr
  21. // interface. It returns a nil interface when the address is
  22. // nil.
  23. sockaddr(family int) (syscall.Sockaddr, error)
  24. // toLocal maps the zero address to a local system address (127.0.0.1 or ::1)
  25. toLocal(net string) sockaddr
  26. }