summary refs log tree commit diff stats
path: root/tests/stdlib/tnetbind.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib/tnetbind.nim')
-rw-r--r--tests/stdlib/tnetbind.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/stdlib/tnetbind.nim b/tests/stdlib/tnetbind.nim
new file mode 100644
index 000000000..84f9ac464
--- /dev/null
+++ b/tests/stdlib/tnetbind.nim
@@ -0,0 +1,25 @@
+discard """
+matrix: "--mm:refc; --mm:orc"
+joinable: false
+"""
+
+#[
+joinable: false
+otherwise:
+Error: unhandled exception: Address already in use [OSError]
+]#
+
+import net
+
+## Test for net.bindAddr
+
+proc test() =
+  # IPv4 TCP
+  newSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1900), "0.0.0.0")
+  newSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1901))
+
+  # IPv6 TCP
+  newSocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1902), "::")
+  newSocket(AF_INET6, SOCK_STREAM, IPPROTO_TCP).bindAddr(Port(1903))
+
+test()