Question: import socket SERVER _ HOST = ' 1 2 7 . 0 . 0 . 1 ' SERVER _ PORT = 5 3 7 8
import socket
SERVERHOST
SERVERPORT
FORBIDDENSYMBOLS @#$&
def readusernames:
usernames set
try:
with openusernamestxtr as file:
for line in file:
usernames.addlinestrip
except FileNotFoundError:
pass # Dosya bulunamazsa bo bir kme dndr
return usernames
def writeusernameusername:
with openusernamestxta as file:
file.writeusername
printWelcome to Chat Client. Enter your login:
username input
existingusernames readusernames
forbidden False
for symbol in FORBIDDENSYMBOLS:
if symbol in username:
forbidden True
break
if forbidden:
printfCannot log in as username That username contains disallowed characters."
elif username in existingusernames:
printfCannot log in as username That username is already in use."
else:
existingusernames.addusername
writeusernameusername
try:
clientsocket socket.socketsocketAFINET, socket.SOCKSTREAM
hostport SERVERHOST, SERVERPORT
clientsocket.connecthostport
printfSuccessfully logged in as username
data clientsocket.recv
if not data:
printSocket is closed."
else:
printfRead data from socket: datadecode
clientsocket.close
except OSError as msg:
printmsg
I am getting errors which are shown in the below. Can you help me to fix them?
x chat Expect client to not restart after a failed log in attempt Failed! The list of tags is RI RT RA
Your client did not start or connected to a wrong server port
x chat Log in with busy server, expect failure, and shut client down gracefully Failed! The list of tags is RI RT RI
Error message is unexpected output at step logging into busy server!
Expected output:
Cannot log in The server is full!
Actual output the last printed line:
Successfully logged in as aRsnlrRvAMMwv!
Total program output:
Welcome to Chat Client. Enter your login:
aRsnlrRvAMMwv
Successfully logged in as aRsnlrRvAMMwv!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
