I use Binary Serialization Object to Read or Write Data Stream and previously if we are going to write/read them we have to compile the "instance class" to be DLL file so we have same Assemblies between them, is it right?
well now, here is my problem:
this is my Binary Sender Code
public void SendBinarySerial(object graph)
{
IFormatter formatter = new BinaryFormatter();
System.Net.Sockets.NetworkStream strm = mClient.GetStream(); //get TCPclient stream
formatter.Serialize(strm, graph);
}
and here is my Binary Receiver code:
private void doRead()
{
do
{
if (mClient.GetStream().CanRead)
{
System.Net.Sockets.NetworkStream strm = mClient.GetStream();
IFormatter formatter = new BinaryFormatter();
object mydat = (object)formatter.Deserialize(strm);//deserialize data receiver
}
} while (true);
}
And this is my "instance class" code that i want to send to the entire of clients. ok Let's consider the following code:
[Serializable()]
public class DataSend
{
public List<Bitmap> MainData = new List<Bitmap>();
public List<string> Title = new List<string>();
}
As you can see , there are several List Variables such as Bitmap and string. the Bitmap data is for image data. if I fill it with many images it will increase the size of variable memory, maybe about 20 mb.
After that I'm about to send them to the entire of clients. Well, here is my question:
Using this technique, if the size object is about 20 mb, will this Work well? I know that Socket Communication has a size limit for sending data
I don't want to define any protocols at all, I just want to use Socket Communication although maybe this is not best way.
Thanks for your response.
I wouldn't worry about size limits using sockets. From my experience it's possible to read/write arbitrary sizes from or to NetworkStream. I would however worry about the serializability of the Bitmap objects. As far as i know this will not serialize the image data.