add socket.disconnected(), used by socketchannle. see #715

This commit is contained in:
Cloud Wu
2017-08-15 13:44:06 +08:00
parent 90536e4a0d
commit f94ca6f4b3
3 changed files with 24 additions and 20 deletions

View File

@@ -104,17 +104,13 @@ function httpc.request(method, host, url, recvheader, header, content)
if timeout then
skynet.timeout(timeout, function()
if not finish then
local temp = fd
fd = nil
socket.shutdown(temp)
socket.shutdown(fd) -- shutdown the socket fd, need close later.
end
end)
end
local ok , statuscode, body = pcall(request, fd,method, host, url, recvheader, header, content)
finish = true
if fd then -- may close by skynet.timeout
socket.close(fd)
end
socket.close(fd)
if ok then
return statuscode, body
else