Hi I'm playing around with the sockets in Python 3.6 and I want to know if my way of checking whether a certain socket is closed or not in the server side is right. Here is the code:
try:
data = s.recv(1024)
print(data)
except socket.error as msg:
print("disconnected")
s.close()
I had tried the one that checks if data
variable is empty but it kept giving me errors when the socket is closed. That's why I had used try catch. Am I doing it right?