tgetaddrinfo.nim 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. exitcode: 0
  4. output: ""
  5. """
  6. # bug: https://github.com/nim-lang/Nim/issues/10198
  7. import nativesockets
  8. import std/assertions
  9. block DGRAM_UDP:
  10. let aiList = getAddrInfo("127.0.0.1", 999.Port, AF_INET, SOCK_DGRAM, IPPROTO_UDP)
  11. doAssert aiList != nil
  12. doAssert aiList.ai_addr != nil
  13. doAssert aiList.ai_addrlen.SockLen == sizeof(Sockaddr_in).SockLen
  14. doAssert aiList.ai_next == nil
  15. freeAddrInfo aiList
  16. when defined(posix) and not defined(haiku) and not defined(freebsd) and not defined(openbsd) and not defined(netbsd):
  17. block RAW_ICMP:
  18. # the port will be ignored
  19. let aiList = getAddrInfo("127.0.0.1", 999.Port, AF_INET, SOCK_RAW, IPPROTO_ICMP)
  20. doAssert aiList != nil
  21. doAssert aiList.ai_addr != nil
  22. doAssert aiList.ai_addrlen.SockLen == sizeof(Sockaddr_in).SockLen
  23. doAssert aiList.ai_next == nil
  24. freeAddrInfo aiList
  25. block RAW_ICMPV6:
  26. # the port will be ignored
  27. let aiList = getAddrInfo("::1", 999.Port, AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)
  28. doAssert aiList != nil
  29. doAssert aiList.ai_addr != nil
  30. doAssert aiList.ai_addrlen.SockLen == sizeof(Sockaddr_in6).SockLen
  31. doAssert aiList.ai_next == nil
  32. freeAddrInfo aiList