Created
April 14, 2020 18:03
-
-
Save vklachkov/6e286985ccc89a553a91ef88a982abc8 to your computer and use it in GitHub Desktop.
Simple tcp server
This file contains 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 | |
SERVER_ADDRESS = ('localhost', 2353) | |
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server_socket.bind(SERVER_ADDRESS) | |
server_socket.listen(1) | |
while True: | |
try: | |
connection, address = server_socket.accept() | |
print("new connection from {address}".format(address=address)) | |
c = 1 | |
while True: | |
connection.send(bytes(str(c), encoding='UTF-8')) | |
c += 1 | |
time.sleep(0.05); | |
except: | |
time.sleep(0.2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment