This is a Python chat room that I've been working on and it enables to you to chat to other people on the same network through Python.
Server.py:
import socket
import sys
s = socket.socket()
host = socket.gethostname()
print(" server will start on host : ", host)
port = 8080
s.bind((host,port))
name = input(str("Please enter your username: "))
print("")
print("Server is waiting for incoming connections")
print("")
s.listen(1)
conn, addr = s.accept()
print("Recieved connection")
print("")
s_name = conn.recv(1024)
s_name = s_name.decode()
print(s_name, "has joined the chat room")
conn.send(name.encode())
while 1:
message = input(str("Please enter your message: "))
conn.send(message.encode())
print("Sent")
print("")
message = conn.recv(1024)
message = message.decode()
print(s_name, ":" ,message)
print("")
Client.py:
import socket
import sys
s = socket.socket()
host = input(str("Please enter the hostname of the server : "))
port = 8080
s.connect((host,port))
name = input(str("Please enter your username : "))
print(" Connected to chat server")
s.send(name.encode())
s_name = s.recv(1024)
s_name = s_name.decode()
print("")
print(s_name, "has joined the chat room ")
while 1:
message = s.recv(1024)
message = message.decode()
print(s_name, ":" ,message)
print("")
message = input(str("Please enter your message: "))
message = message.encode()
s.send(message)
print("Sent")
print("")
I just wanted suggestions on how I can to improve this chatroom to make it better and faster. All suggestions will be greatly appreciated.