I am building this socket application and every time I am getting the following error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Here are the relevant lines from the server:
filename = client_sock.recv(1024).decode()
filesize = client_sock.recv(1024).decode()
Here are the relevant lines from the client:
self.sock.send(file_dir.encode())
self.sock.send(str(filesize).encode())
The error message happens on the second line of the server. (filesize =) Here are prints showing what the client will send to the server.
print(file_dir) # Output is D:/Statispic2/Photos/photo3.jpg
print(filesize) # Output is 96523
This error only happens sometimes which is really weird. I have looked at other questions that asked a similar question but their solutions either didn't work or weren't relevant.
If you want to see the whole code or have any more questions please let me know! Thanks a lot!