tnetbind.nim 536 B

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