summaryrefslogtreecommitdiff
path: root/ThirdParty/luasocket/test/udpconnectclnt.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-20 13:40:34 +0800
committerchai <chaifix@163.com>2021-10-20 13:40:34 +0800
commitff0f488c97fe8b554b909a0057cebc4c860eac8f (patch)
tree4e47262b52ffce7e9cfeaaeeab46371243bcaa78 /ThirdParty/luasocket/test/udpconnectclnt.lua
parentdde719dd575090b36aaa3ad85bb3cabf33f36c5a (diff)
+luasocket src
Diffstat (limited to 'ThirdParty/luasocket/test/udpconnectclnt.lua')
-rw-r--r--ThirdParty/luasocket/test/udpconnectclnt.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/ThirdParty/luasocket/test/udpconnectclnt.lua b/ThirdParty/luasocket/test/udpconnectclnt.lua
new file mode 100644
index 0000000..ad6ab6a
--- /dev/null
+++ b/ThirdParty/luasocket/test/udpconnectclnt.lua
@@ -0,0 +1,19 @@
+local socket = require"socket"
+local udp = socket.udp
+local localhost = "127.0.0.1"
+local port = assert(arg[1], "missing port argument")
+
+se = udp(); se:setoption("reuseaddr", true)
+se:setsockname(localhost, 5062)
+print("se", se:getsockname())
+sc = udp(); sc:setoption("reuseaddr", true)
+sc:setsockname(localhost, 5061)
+print("sc", sc:getsockname())
+
+se:sendto("this is a test from se", localhost, port)
+socket.sleep(1)
+sc:sendto("this is a test from sc", localhost, port)
+socket.sleep(1)
+se:sendto("this is a test from se", localhost, port)
+socket.sleep(1)
+sc:sendto("this is a test from sc", localhost, port)