Skip to content

Instantly share code, notes, and snippets.

@WilliamNT
Last active September 13, 2021 16:02
Show Gist options
  • Save WilliamNT/22c9e6b22ede6a5b9319316038d6a9bc to your computer and use it in GitHub Desktop.
Save WilliamNT/22c9e6b22ede6a5b9319316038d6a9bc to your computer and use it in GitHub Desktop.
import socket
import time
class Client():
def __init__(self, delay: None, address: None):
if delay < 0.5:
delay = 0.5
self.delay = delay
if not address:
address = "localhost"
self.address = address
self.port = 30001
self.data_size = 30000
def receiver(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((self.address, self.port))
data = sock.recv(self.data_size)
return data
def client(self):
while True:
time.sleep(self.delay)
self.receiver()
client = Client(delay=1, address="localhost")
print(client.client())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment