[Unet] Problems with sending data to the client

Am trying to send a list with data to the client but when there is more then 3 entries in the list it will throw me an exception: NotSupportedException: Memory stream is not expandable.

    public void SendClient(int connectionId, Packet packet)
    {
        byte[] buffer = new byte[Utility.BYTE_SIZE];

        BinaryFormatter formatter = new BinaryFormatter();
        MemoryStream memoryStream = new MemoryStream(buffer);
        formatter.Serialize(memoryStream, packet); //< Where it throws the exception

        NetworkTransport.Send(hostId, connectionId, reliableChannel, buffer, Utility.BYTE_SIZE, out error);
    }

When i increase the byte size (both on the server & client) the client wont connect to the server anymore

Anyone got some solution for this, its not a game i plan to release but i do like messing about with it for my own personal learning outside school

Figured out my problem, i do have another question tho, is there a way to increase the packet size above 2000?

“When i increase the byte size (both on the server & client) the client wont connect to the server anymore”
What does it mean? What do you increase? Utility.BYTE_SIZE in your code? it cannot affect connect, but Send() will probably return error - messageTooLong of Utility.BYTE_SIZE > PacketSize… Did you check the error?

" packet size above 2000" yes sure, you can increase them but assign new size to ConnectionConfig.PacketSize (it should be the same value for both communicating peers or you connect attempt will finish with error CRCMismatch)
But, note that default ethernet value is 1440 so setting 2000 will cause packet defragmentation and will double the possibility of packet loss… Transport has special qos for long messages why u don’t want to use them by configuring channel with any qos having …Fragmented… in name?

Note that from my own testing some network providers drop UDP packets of sizes much higher than 500 bytes. I suspect they are just dropping anything larger than 576 bytes, since they are required to handle 576 or lower (RFC 791).