summaryrefslogtreecommitdiff
path: root/script/proto/proto.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-05-22 18:03:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-05-22 18:04:01 +0800
commitd8f2ce4a7e7068f0d81cd48a4589226eec249415 (patch)
tree6ec1054ef804d658f67f8daa74f16c78c6b52478 /script/proto/proto.lua
parent86e2d589c30e73198226b11c4248a31fada4e620 (diff)
downloadlua-language-server-d8f2ce4a7e7068f0d81cd48a4589226eec249415.zip
better socket
Diffstat (limited to 'script/proto/proto.lua')
-rw-r--r--script/proto/proto.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/script/proto/proto.lua b/script/proto/proto.lua
index fb623106..7a196c35 100644
--- a/script/proto/proto.lua
+++ b/script/proto/proto.lua
@@ -237,10 +237,15 @@ function m.listen(mode, socketPort)
io.stdout:setvbuf 'no'
pub.task('loadProtoByStdio')
elseif mode == 'socket' then
- local fd = assert(socket('tcp'))
- fd:connect('127.0.0.1', socketPort)
- m.fd = fd
- pub.task('loadProtoBySocket', fd:handle())
+ local rfd = assert(socket('tcp'))
+ rfd:connect('127.0.0.1', socketPort)
+ local wfd1, wfd2 = socket.pair()
+ m.fd = wfd1
+ m.fdRefs = { rfd, wfd1, wfd2 }
+ pub.task('loadProtoBySocket', {
+ wfd = wfd2:handle(),
+ rfd = rfd:handle(),
+ })
end
end