hi guys
it`s question about , sending data separately , im send one integer as info form my sensor to server program , i want to send another integer as another sensor to server but there is problem how separate them from each other , and how i can understand which on that i get it in my server program :
client program : Void send
<pre lang="cs">
void sendata(int d)
{
byte[] data = new byte[1024];
data = BitConverter.GetBytes(d);
sock.Send(data, data.Length, SocketFlags.None);
}
then i call this void in this timer and send data to server :
<pre lang="cs">
private void timer1_Tick(object sender, EventArgs e)
{
try
{
sendata(a);
}
catch
{
}
}
and use this code in server :
private void timer1_Tick(object sender, EventArgs e)
{
DateTime startTime = DateTime.Now;
byte[] data = new byte[1024];
int recv = client.Receive(data);
int size = BitConverter.ToInt32(data, 0);
if (recv != 0)
{
label3.Text = " ";
label3.Text = "co2 ppm is : " + size;
}
progressBar1.Maximum = 100;
progressBar1.Minimum = 0;
progressBar1.Value = size;
label2.Text = DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString() + " :Time To Action" + " ms ";
}
please tell me how i can send two or more data (int) and get and separate them in server ...