added file protocol
fixed encoding of message lenght (len of bytes instead of len of string)