Hi,
i use a UDP-socket for sending/receiving objects. I serialize the objects into a byte array send it and receive it with a client. But before i can receive i have to allocate a byte array. I must do it before and then handle the Socket.Receive()-methode the array. But my objects have a variable length. How can i discover the array-size?
Thank you
Edit: Here a example of my receive-methode:
BinaryFormatter bf = new BinaryFormatter();
public Object ReceiveUdpPacket()
{
byte[] objData = new byte[bufferSize];
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 0);
EndPoint ep = (EndPoint)ipep;
MemoryStream ms = new MemoryStream();
udpSocket.ReceiveFrom(objData, ref ep);
ms.Write(objData, 0, objData.Length);
ms.Seek(0, SeekOrigin.Begin);
return (Object)bf.Deserialize(ms);
}