diff options
Diffstat (limited to 'test/udpconnectclnt.lua')
-rw-r--r-- | test/udpconnectclnt.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/udpconnectclnt.lua b/test/udpconnectclnt.lua new file mode 100644 index 0000000..effe13a --- /dev/null +++ b/test/udpconnectclnt.lua | |||
@@ -0,0 +1,19 @@ | |||
1 | local socket = require"socket" | ||
2 | local udp = socket.udp | ||
3 | local localhost = "127.0.0.1" | ||
4 | local port = arg[1] | ||
5 | |||
6 | se = udp(); se:setoption("reuseaddr", true) | ||
7 | se:setsockname(localhost, 5062) | ||
8 | print("se", se:getsockname()) | ||
9 | sc = udp(); sc:setoption("reuseaddr", true) | ||
10 | sc:setsockname(localhost, 5061) | ||
11 | print("sc", sc:getsockname()) | ||
12 | |||
13 | se:sendto("this is a test from se", localhost, port) | ||
14 | socket.sleep(1) | ||
15 | sc:sendto("this is a test from sc", localhost, port) | ||
16 | socket.sleep(1) | ||
17 | se:sendto("this is a test from se", localhost, port) | ||
18 | socket.sleep(1) | ||
19 | sc:sendto("this is a test from sc", localhost, port) | ||