Created
October 18, 2016 23:29
-
-
Save ubershmekel/7b0f18d19db8be012cac50a428deb13e to your computer and use it in GitHub Desktop.
Just for when you need a socket to always timeout
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
# Echo server program | |
import socket | |
import time | |
# Symbolic name meaning all available interfaces | |
HOST = '' | |
# Arbitrary non-privileged port | |
PORT = 18080 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((HOST, PORT)) | |
s.listen(1) | |
conn, addr = s.accept() | |
print 'Connected by', addr | |
while True: | |
data = conn.recv(1024) | |
print('Recv-ed %d bytes' % len(data)) | |
time.sleep(1) | |
#if not data: break | |
#conn.sendall(data) | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment