tgetaddrinfo.nim 1.2 KB

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