mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-12 16:28:22 +01:00
6368caeb5a
There seems to be a curious difference between MacOS and Linux and I am not sure if this is documented. When you break a "connection" on Mac OS, you only eliminate the peer association, but the local address remains bound. On Linux, breaking a "connection" eliminates the binding to the local address. Have you guys ever come accross this? Another irritating difference is that connect() returns the error EAFNOSUPPORT on Mac OS. I am going to ignore all errors when the reason for calling connect() is simply to break the "connection".
20 lines
578 B
Lua
20 lines
578 B
Lua
local socket = require"socket"
|
|
local udp = socket.udp
|
|
local localhost = "127.0.0.1"
|
|
local port = arg[1]
|
|
|
|
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)
|