Packing and unpacking a dictionary of key-value pairs over the socket.