å¥ä»¶ã§Nginxã®ã½ã¼ã¹ãgdbã§ãããã°ããªããè¦ã¦ããlingering_closeããªãããã¨ãããã¹ãè¦ã¤ããã®ã§ãã£ãããªã®ã§èª¿ã¹ã¦ã¿ããlingeringã¯ä½é»ã¨ããæå³ã§ã¯ã©ã¤ã¢ã³ã/ãµã¼ãã¢ãã«ã®ã·ã¹ãã ããã£ãã¨ãã¦ãµã¼ãå´ãã¢ã¯ãã£ãã¯ãã¼ãºã«ãªãã±ã¼ã¹ã§ãµã¼ãã¯write(2)ããç´å¾ã«close(2)ãshutdown(2)ãããã¨write(2)ã®ãã¼ã¿ãã¯ã©ã¤ã¢ã³ãã«å±ãã¦ããªãã¿ãããªã±ã¼ã¹ããããããã¯write(2)ã¯ãã¼ã«ã«ã®ã½ã±ãããããã¡ã¼ã«ãã¼ã¿ãæ¸ãããå¦çãæ»ãããã«èµ·ããã以ä¸ã®ãããªãµã¼ããæ¸ãã¦ã¿ãã
import socket import struct sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(("127.0.0.1", 8080)) sock.listen(10) while True: client,address = sock.accept() print("[*] Connected!! [ Source : {}]".format(address)) data = client.recv(1024) print("[*] Received Data : {}".format(data)) client.send(b"a"*1024) client.close() print("close!!")