Skip to content
Snippets Groups Projects
Commit 69ae38c1 authored by Ethan Robert's avatar Ethan Robert
Browse files

Erased everything

parent cba38970
No related branches found
No related tags found
No related merge requests found
import socket
FILE = 'message.txt'
class Socket:
def __init__(self):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.bind(('0.0.0.0', 25566))
self.message = ""
def readMessage(self):
with open(FILE, 'r') as file:
self.message = file.read()
def start(self):
self.socket.listen(1)
while True:
client_socket, client_address = self.socket.accept()
# Grab the new message from the file
readMessage()
if self.message == '':
client_socket.close()
else:
# Send the message to the client (teacher)
client_socket.send(self.message.encode('UTF-8'))
# Wait for the pong
response = client_socket.recv(1024).decode('UTF-8')
if response == "Ok":
self.message = ""
client_socket.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment