I am trying to send over sockets an Enum value, but however no matter what I try it gets encoded as a string (except when I manually convert it to bytes in the call to the socket.send)
class Example(Enum):
A = b'example'
B = bytes('example', 'utf8')
I call the send method from the socket module where sock is a prior bound socket for a server
....
conn, addr = sock.accept()
conn.send(Example.A.name)
and the exception message is:
a bytes-like object is required, not 'str'
I have read this and some other links but I could not find the answer.