tgetaddrinfo.nim 1.1 KB

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