| 1 | local socket = require"socket" |
| 2 | local udp = socket.udp |
| 3 | local localhost = "127.0.0.1" |
| 4 | local port = assert(arg[1], "missing port argument") |
| 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) |