I'm trying to send a custom object via sockets in Python. My object is defined as:
packet = Packet.Packet(MAGIC_NUMBER,0,sender_next,packet_size,local_buffer)
port_out.send(packet)
But I am getting an error of: builtins.TypeError: a bytes-like object is required, not 'Packet'
I've seen previous posts about using .encode() for str types but how do I do it for a custom object like this? Do I need to make a encode method?