I have this Server/Client app written in C#. There is an SQL Server on server side, when client needs a table it sends a request to server application and server application connects to SQL Server and retrieves the table and sends it to client via a NetworkStream.
This is the server side code which sends the DataSet XML Stream
using (var networkStream = new NetworkStream(m_workerSocket[0]))
{
dataSet.WriteXml(networkStream);
}
And I’m reading this xml file as bytes and convert it to string and convert it to a DataSet again.
This is client side code:
TextReader reader = new StringReader(richTextRxMessage.Text);
DataSet dataSet = new DataSet();
dataSet.ReadXml(reader);
DataTable dtProd = new DataTable();
dataGridView1.DataSource = dataSet.Tables[0];
My question is is this an efficient way to send table between client/server? Would it be a problem with big tables such as 10k entries? What can I do to optimize that?
And there will be a lot of communication between server and client except these tables such as instant messages or different type of files. So how can I handle and classify a lot of data wheter its a file or its a DataSet etc. For example should I put custom string tags (such as <DATASET>, <DOCFILE> etc.) before sending data to identify data type that I’m sending?
Thank you.
PS:I’m using Asynchronous Server and Client to sends and recieve data.
You should use WCF for such tasks.
You can read about it here