Last active
September 13, 2021 16:02
-
-
Save WilliamNT/22c9e6b22ede6a5b9319316038d6a9bc to your computer and use it in GitHub Desktop.
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 | |
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