tnetbind.nim 506 B

12345678910111213141516171819202122232425
  1. discard """
  2. joinable: false
  3. """
  4. #[
  5. joinable: false
  6. otherwise:
  7. Error: unhandled exception: Address already in use [OSError]
  8. ]#
  9. import net
  10. ## Test for net.bindAddr
  11. proc test() =
  12. # IPv4 TCP
  13. newSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1900), "0.0.0.0")
  14. newSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1901))
  15. # IPv6 TCP
  16. newSocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1902), "::")
  17. newSocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1903))
  18. test()