Socket accepts data will come to a standstill.

problems encountered when starting to learn socket (python),
Liao Xuefeng"s socket learning website:
https://www.liaoxuefeng.com/w.
problem: when the while cycle accepts the returned content from Baidu, the last acceptance will stay for a long time, and the normal access request is certainly not so slow. I don"t know what the problem is.
attach your own code:

-sharp socket:
import socket

-sharp socket:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-sharp :
s.connect(("www.baidu.com", 80))
-sharp :
s.send(b"GET / HTTP/1.1\r\nHost:www.baidu.com\r\n\r\n")

-sharp :
buffer = []
while True:
    -sharp 1k:
    d = s.recv(1024)
    -sharp1024d==""
    print(d)
    if d:
        buffer.append(d)
    else:
        break
data = b"".join(buffer)
s.close()
header, html = data.split(b"\r\n\r\n", 1)
print(header.decode("utf-8"))
-sharp :
with open("sina.html", "wb") as f:
    f.write(html)

stop for several seconds (red box)

clipboard.png

May.02,2021

s.send(b'GET / HTTP/1.1\r\nHost:www.baidu.com\r\nConnection: close\r\n\r\n')

active shutdown after request

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bfa7-4131a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bfa7-4131a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?