Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local server = luasocket.TCPServer()
- server:Bind("localhost", 1000)
- local client = luasocket.TCPClient()
- client:Connect("localhost", 1000)
- client:Send("hello\n")
- client:Send("hello\n")
- client:Send("hello\n")
- client:Send("hello\n")
- --[[
- server_tcp[127.0.0.1][1000] - client_tcp[127.0.0.1][22874] connected
- client_tcp[127.0.0.1][1000] - connected to 127.0.0.1:1000
- client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
- server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
- client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
- server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
- client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
- server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
- client_tcp[127.0.0.1][1000] - sucessfully sent "hello\n"
- server_tcp[127.0.0.1][1000] - received hello from client_tcp[127.0.0.1][22874]
- server_tcp[127.0.0.1][1000] - client_tcp[127.0.0.1][22874] wants to close
- ]]
- --[[
- server functions:
- server:Bind(ip, port)
- table server:GetClients()
- sevrer:Remove()
- server:GetIp()
- server:GetPort()
- server:IsValid()
- server callbacks:
- server.OnClientConnect(client)
- server.OnClientClose(client)
- server.OnClientError(client)
- server.OnReceive(line, client)
- server.OnError(err)
- client functions:
- client:Connect(ip, port)
- client:Send()
- client:IsConnected()
- client:IsSending()
- client:Remove()
- client:GetIp()
- client:GetPort()
- client:IsValid()
- client callbacks:
- client.OnConnect(ip, port)
- client.OnSend(data)
- client.OnClose()
- client.OnReceive(data)
- client.OnError()
- ]]
Advertisement
Add Comment
Please, Sign In to add comment