Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do -- UDP
- local server = luasocket.Server("udp")
- server:Host("10.0.0.1", 888)
- function server:OnReceive(data, ip, port)
- server:Send("hi", ip, port)
- end
- local client = luasocket.Client("udp")
- client:Connect("10.0.0.1", 888)
- client:Send("hello")
- client:Send("hello")
- client:Send("hello")
- client:Send("hello")
- end
- do -- TCP
- local server = luasocket.Server("tcp")
- server:Host("10.0.0.1", 555)
- function server:OnReceieve(data, client)
- self:Send("hi", client:GetIP())
- end
- local client = luasocket.Client("tcp")
- client:Connect("10.0.0.1", 555)
- client:Send("hello\n")
- client:Send("hello\n")
- client:Send("hello\n")
- client:Send("hello\n")
- end
Advertisement
Add Comment
Please, Sign In to add comment