Created
September 21, 2023 07:21
-
-
Save outsinre/8b3987e3b4d6a12aac4962555ef70efd to your computer and use it in GitHub Desktop.
The send buffer has data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local socket = require("socket") | |
local host, port = "180.101.50.242", 80 | |
local sock = socket.connect(host, port) | |
sock:settimeout(1) | |
sock:send("GET / HTTP/1.1\r\n\r\n") | |
sock:close() |
Fix:
local socket = require("socket")
local host, port = "www.baidu.com", 80
local sock = socket.connect(host, port)
sock:settimeout(1)
sock:send("GET / HTTP/1.1\r\n\r\n")
while true do
local line, err = sock:receive()
if err == "timeout" then
break
end
end
sock:close()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sock;close()
will cause TCP RST, as the receiving buffer has data.