def handle_client(self, client_socket, address):
size = 1024
while True:
try:
data = client_socket.recv(size)
if 'q^' in data.decode():
print('Received request for exit from: ' + str(address[0]) + ':' + str(address[1]))
break
else:
body = data.decode()
except socket.error:
client_socket.close()
return False
client_socket.sendall('Received request for exit. Deleted from server threads'.encode())
client_socket.sendall('q^'.encode())
client_socket.close()
The error happens on if 'q^' in data.decode():
The data comes from an iOS client
connection.send(content: "SOME_STRING".data(using: .utf8)!, completion: NWConnection.SendCompletion.contentProcessed({ error in
print(error)
}))
There are similar questions on SO, but non of the solutions solved the problem