CapsAdmin

Untitled

Mar 14th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.62 KB | None | 0 0
  1. local server = luasocket.TCPServer()
  2. server:Bind("localhost", 1000)
  3.  
  4. local client = luasocket.TCPClient()
  5. client:Connect("localhost", 1000)
  6. client:Send("hello\n")
  7. client:Send("hello\n")
  8. client:Send("hello\n")
  9. client:Send("hello\n")
  10.  
  11. --[[
  12. server_tcp[127.0.0.1][1000] - client_tcp[127.0.0.1][22874] connected
  13. client_tcp[127.0.0.1][1000] - connected to 127.0.0.1:1000
  14. client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
  15. server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
  16. client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
  17. server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
  18. client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
  19. server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
  20. client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
  21. server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
  22. server_tcp[127.0.0.1][1000] - client_tcp[127.0.0.1][22874] wants to close
  23. ]]
  24.  
  25. --[[
  26. server functions:
  27.     server:Bind(ip, port)
  28.     table server:GetClients()
  29.    
  30.     sevrer:Remove()
  31.     server:GetIp()
  32.     server:GetPort()
  33.     server:IsValid()
  34.  
  35. server callbacks:
  36.     server.OnClientConnect(client)
  37.     server.OnClientClose(client)
  38.     server.OnClientError(client)
  39.  
  40.     server.OnReceive(line, client)
  41.     server.OnError(err)
  42.  
  43. client functions:
  44.     client:Connect(ip, port)
  45.     client:Send()
  46.    
  47.     client:IsConnected()
  48.     client:IsSending()
  49.    
  50.     client:Remove()
  51.     client:GetIp()
  52.     client:GetPort()
  53.     client:IsValid()
  54.    
  55. client callbacks:
  56.     client.OnConnect(ip, port)
  57.     client.OnSend(data)
  58.     client.OnClose()
  59.     client.OnReceive(data)
  60.     client.OnError()
  61. ]]
Advertisement
Add Comment
Please, Sign In to add comment