initial commit, basic client chat

This commit is contained in:
Daniel Jones 2024-09-11 13:17:11 -05:00
commit 17c5c8557d
2 changed files with 33 additions and 0 deletions

14
client.py Normal file
View File

@ -0,0 +1,14 @@
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(("localhost", 9999))
done = False
while not done:
client.send(input("message: ").encode('utf-8'))
msg = client.recv(1024).decode('utf-8')
if msg != "quit":
print(msg)
else:
done = True

19
server.py Normal file
View File

@ -0,0 +1,19 @@
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("localhost", 9999))
server.listen()
client, addr = server.accept()
done = False
while not done:
msg = client.recv(1024).decode('utf-8')
if msg == 'quit':
done = True
else:
print(msg)
client.send(input("Message: ").encode('utf-8'))