add socket.limit for defence

This commit is contained in:
Cloud Wu
2014-07-12 20:30:02 +08:00
parent 54e6d03d36
commit 3a5de32ad0
3 changed files with 23 additions and 3 deletions

View File

@@ -21,6 +21,9 @@ if mode == "agent" then
id = tonumber(id)
skynet.start(function()
-- A small limit, if socket buffer overflow, close the client
socket.limit(64)
skynet.fork(function()
echo(id)
skynet.exit()
@@ -30,7 +33,7 @@ else
local function accept(id)
socket.start(id)
socket.write(id, "Hello Skynet\n")
skynet.newservice("testsocket", "agent", id)
skynet.newservice(SERVICE_NAME, "agent", id)
-- notice: Some data on this connection(id) may lost before new service start.
-- So, be careful when you want to use start / abandon / start .
socket.abandon(id)