add getprotobyname (#15273)

* add getprotobyname

* tests, docs, changelog

* add since
This commit is contained in:
flywind 2020-09-09 18:47:22 +08:00 • committed by GitHub
commit 8c82144ba5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,25 @@
discard """
cmd: "nim c -r --styleCheck:hint --panics:on $options $file"
targets: "c"
nimout: ""
action: "run"
exitcode: 0
timeout: 60.0
"""
import nativesockets
doAssert getProtoByName("ip") == 0
doAssert getProtoByName("ipv6") == 41
doAssert getProtoByName("tcp") == 6
doAssert getProtoByName("udp") == 17
doAssert getProtoByName("icmp") == 1
doAssert getProtoByName("ipv6-icmp") == 58
when defined(windows):
doAssertRaises(OSError):
discard getProtoByName("raw")
doAssertRaises(OSError):
discard getProtoByName("Error")