Last active
April 29, 2019 12:34
-
-
Save nishidy/dd2f6f4ee39061231bc5c02126d6d4fa to your computer and use it in GitHub Desktop.
TCP KEEPALIVE and TIME_WAIT
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
import socket | |
import time | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect(('xxxxxxxx', 8080)) | |
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) | |
s.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, 35) | |
s.send(b'GET / HTTP/1.1\r\nHost: localhost') | |
data = s.recv(1024) | |
print(data) | |
time.sleep(180) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.