initial commit, basic client chat
This commit is contained in:
commit
17c5c8557d
14
client.py
Normal file
14
client.py
Normal 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
19
server.py
Normal 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'))
|
Loading…
Reference in New Issue
Block a user