mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 06:04:31 +02:00
Fix udp:setpeername("*")
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".
This commit is contained in:
16
test/udpconnectsrvr.lua
Normal file
16
test/udpconnectsrvr.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local socket = require"socket"
|
||||
local udp = socket.udp
|
||||
local localhost = "127.0.0.1"
|
||||
local s = assert(udp())
|
||||
assert(tostring(s):find("udp{unconnected}"))
|
||||
print("setpeername", s:setpeername(localhost, 5061))
|
||||
print("getsockname", s:getsockname())
|
||||
assert(tostring(s):find("udp{connected}"))
|
||||
print(s:receive())
|
||||
print("setpeername", s:setpeername("*"))
|
||||
print("getsockname", s:getsockname())
|
||||
s:sendto("a", localhost, 12345)
|
||||
print("getsockname", s:getsockname())
|
||||
assert(tostring(s):find("udp{unconnected}"))
|
||||
print(s:receivefrom())
|
||||
s:close()
|
Reference in New Issue
Block a user