tgetprotobyname.nim 683 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. cmd: "nim c -r --styleCheck:hint --panics:on $options $file"
  3. targets: "c"
  4. nimout: ""
  5. action: "run"
  6. exitcode: 0
  7. timeout: 60.0
  8. """
  9. import nativesockets
  10. when not defined(netbsd):
  11. # Ref: https://github.com/nim-lang/Nim/issues/15452 - NetBSD doesn't define an `ip` protocol
  12. doAssert getProtoByName("ip") == 0
  13. doAssert getProtoByName("ipv6") == 41
  14. doAssert getProtoByName("tcp") == 6
  15. doAssert getProtoByName("udp") == 17
  16. doAssert getProtoByName("icmp") == 1
  17. doAssert getProtoByName("ipv6-icmp") == 58
  18. when defined(windows):
  19. doAssertRaises(OSError):
  20. discard getProtoByName("raw")
  21. doAssertRaises(OSError):
  22. discard getProtoByName("Error")