mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
change source dir
This commit is contained in:
25
service/testconn.lua
Normal file
25
service/testconn.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local skynet = require "skynet"
|
||||
|
||||
-- register a dummy callback function
|
||||
skynet.dispatch()
|
||||
|
||||
local connection = skynet.launch("connection","16")
|
||||
print("connection",connection)
|
||||
|
||||
skynet.start(function()
|
||||
local fd = skynet.call(".connection","CONNECT 127.0.0.1:8000")
|
||||
if fd == nil then
|
||||
print("Connect failed")
|
||||
skynet.exit()
|
||||
return
|
||||
end
|
||||
print("connect to ",fd)
|
||||
skynet.send(".connection","WRITE "..fd.." Welcome\n")
|
||||
local four = skynet.call(".connection","READ "..fd .." 4")
|
||||
print("READ 4", four)
|
||||
local line = skynet.call(".connection","READLINE "..fd .." \n")
|
||||
skynet.send(".connection","WRITE "..fd.." "..line.."\n")
|
||||
skynet.send(".connection","CLOSE "..fd)
|
||||
|
||||
skynet.exit()
|
||||
end)
|
||||
Reference in New Issue
Block a user