I'm creating a program that activates the timer after receiving the time, ID, and password through the socket. and when i input "minute" value, I have winError 10053. I can't understand, why name and hour can be sent, not minute?
this is client code
declStart = input("if you want to login, enter "login" ") # GUI 생기면 버튼으로 대체
if declStart=="login":
while True:
cname = str(input('enter name :'))
if ' ' in cname:
print('Spaces are not allowed.')
continue
client_sock.send(cname.encode())
is_possible_name = client_sock.recv(1024).decode()
if is_possible_name == 'yes':
client_sock.send('!enter'.encode())
goaltime_hour = int(input('goaltime(hour): '))
client_sock.send((str(goaltime_hour)).encode())
goaltime_min = int(input('goaltime(min): '))
client_sock.send((str(goaltime_min)).encode())
goaltime_sec = int(input('goaltime(sec): '))
client_sock.send((str(goaltime_sec)).encode())
elif is_possible_name == 'overlapped':
print('[SYSTEM] The name already exists.')
elif len(client_sock.recv(1024).decode()) == 0:
print('[SYSTEM] The server has been disconnected.')
client_sock.close()
os._exit(1)
while True:
if goaltime_hour <= 0 and goaltime_min <= 0:
print('Please enter the time')
continue
elif (str(type(goaltime_hour)) != "<class 'int'>") or (str(type(goaltime_min)) != "<class 'int'>"):
print("Please enter the int")
continue
else: break
pw = input("enter password")
client_sock.send((str(pw)).encode())
print("login completed. \n ")
break
server
class timeuser:
name: str=None
goaltime_hour: int=None
goaltime_min: int=None
goaltime_sec: int=None
currsecond: int=0
while True:
count = count 1
conn, addr = server_sock.accept()
client=timeuser()
while True:
username = conn.recv(1024).decode()
if not username in member_name_list:
conn.send('yes'.encode())
break
else:
conn.send('overlapped'.encode())
client.name = username
clientHour = int(conn.recv(1024).decode()) # 시간수신
client.goaltime_hour = clientHour
clientMin = int(conn.recv(1024).decode()) # 분수신
client.goaltime_min = clientMin
clientsec = int(conn.recv(1024).decode()) # 초수신
client.goaltime_sec = clientsec
you can see entire code here : https://github.com/whataLIN/Pysoc_myStudyTimer
I deleted All other data transmission and reception processes except hour and name, Then it worked fine. I want to get other data with no error..
CodePudding user response:
Error 10053 is "Connection reset" (WSAECONNRESET
). It means the server closed its socket.
That is probably because the client sends !enter
and the server tries to read it as a number and crashes. If you looked at the terminal where the server was running, you would see it crash.