diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-10-14 14:45:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-10-14 14:45:22 +0800 |
commit | c876e0da1c0c2d01db9cb0c6f2914659318e0460 (patch) | |
tree | b062136c074242499e75cc41c10ef5bc5a4cdce8 /script/service/net.lua | |
parent | c38be0c4e0e409cd9c2531e7dddb5ef478f8093f (diff) | |
download | lua-language-server-c876e0da1c0c2d01db9cb0c6f2914659318e0460.zip |
fix telemetry
Diffstat (limited to 'script/service/net.lua')
-rw-r--r-- | script/service/net.lua | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/script/service/net.lua b/script/service/net.lua index 9ccd119a..61603d79 100644 --- a/script/service/net.lua +++ b/script/service/net.lua @@ -258,18 +258,35 @@ end local m = {} -function m.listen(...) - local fd, err = socket.bind(...) +function m.listen(protocol, ...) + local fd, err = socket(protocol) if not fd then - return fd, err + return nil, err + end + local ok + ok, err = fd:bind(...) + if not ok then + fd:close() + return nil, err + end + ok, err = fd:listen() + if not ok then + fd:close() + return nil, err end return new_listen(fd) end -function m.connect(...) - local fd, err = socket.connect(...) +function m.connect(protocol, ...) + local fd, err = socket(protocol) if not fd then - return fd, err + return nil, err + end + local ok + ok, err = fd:connect(...) + if ok == nil then + fd:close() + return nil, err end return new_connect(fd) end |