-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path37-test.lua
76 lines (67 loc) · 2.64 KB
/
37-test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
local skynet = require("skynet")
local socket = require("skynet.socket")
-- function callback(id,size)
-- skynet.error(id," 写缓冲区过载:",size)
-- end
function connect(cID,addr)
-- socket.close_fd(cID)
socket.start(cID)
-- socket.warning(cID,callback)
-- skynet.timeout(200,function() socket.close(cID) end)
-- skynet.timeout(200,function() socket.shutdown(cID) end)
while true do
-- skynet.yield()
-- socket.block(cID)
-- skynet.error("哈哈哈哈哈哈阿哈哈哈哈哈哈")
-- local str = socket.read(cID,1)
str = "aaa"
if str then
-- skynet.error("read:",str)
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
-- socket.write(cID,string.upper(str))
else
-- socket.close(cID)
skynet.error("客户端",addr,"已断开连接")
skynet.error("str",str)
return
end
end
end
function accept(cID,addr)
skynet.error("客户端",addr,"已连接")
skynet.fork(connect,cID,addr)
end
skynet.start(function()
lID = socket.listen("0.0.0.0",8900)
socket.start(lID,accept)
end)