Last active
November 28, 2025 08:28
-
-
Save outsinre/8b3987e3b4d6a12aac4962555ef70efd to your computer and use it in GitHub Desktop.
The send buffer has data
This file contains hidden or 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") | |
| socket.sleep(1) | |
| sock:close() |
Author
Author
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()
Author
See #tcp-close
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sock;close()will send TCP RST to passive closer, as the receiving buffer has data.