File: udpconnectsrvr.lua

package info (click to toggle)
luasocket 3.0~rc1%2Bgit%2Bac3201d-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 2,216 kB
  • sloc: ansic: 4,487; makefile: 320; sh: 116
file content (16 lines) | stat: -rw-r--r-- 533 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()