Created
September 25, 2019 14:28
-
-
Save Ra1d7/4b66c34e99642cf446b46fd831a7c52c to your computer and use it in GitHub Desktop.
The Client for the "chat app" , you run the server first then this (this is only a concept not even close to what work is needed for a real chat app)
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 threading | |
s= socket.socket(socket.AF_INET,socket.SOCK_STREAM) | |
s.connect((socket.gethostname(),1234)) | |
def send(): | |
global s | |
while True: | |
s.send(bytes( | |
input('MSG: '),'utf-8')) | |
def recieve(): | |
while True: | |
global s | |
msg = s.recv(1024).decode('utf-8') | |
print(f'Server: \033[32m{msg}\033[0m\n') | |
t1 = threading.Thread(target=send) | |
t2 = threading.Thread(target=recieve) | |
t1.start() | |
t2.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment