CapsAdmin

Untitled

Mar 22nd, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. do -- UDP
  2.     local server = luasocket.Server("udp")
  3.     server:Host("10.0.0.1", 888)
  4.    
  5.     function server:OnReceive(data, ip, port)
  6.         server:Send("hi", ip, port)
  7.     end
  8.  
  9.     local client = luasocket.Client("udp")
  10.         client:Connect("10.0.0.1", 888)
  11.         client:Send("hello")
  12.         client:Send("hello")
  13.         client:Send("hello")
  14.         client:Send("hello")
  15. end
  16.  
  17. do -- TCP
  18.     local server = luasocket.Server("tcp")
  19.         server:Host("10.0.0.1", 555)
  20.        
  21.         function server:OnReceieve(data, client)
  22.             self:Send("hi", client:GetIP())
  23.         end
  24.    
  25.     local client = luasocket.Client("tcp")
  26.         client:Connect("10.0.0.1", 555)
  27.         client:Send("hello\n")
  28.         client:Send("hello\n")
  29.         client:Send("hello\n")
  30.         client:Send("hello\n")
  31. end
Advertisement
Add Comment
Please, Sign In to add comment