I am trying to send a value by socket .So i have two parts in my project Client and server .
The client sends a value to serve
As far as I can tell from your code, you are sending data as a string in binary format, this will yield bytes for the characters 1,2.
When you read the data back you try to get Int32 values.
There are two options here:
Read and write data as a string.
Client code:
binaryWriter.Write("1,2");
Server code:
string text = binaryReader.ReadString(); // "1,2"
OR Read and write data as integers.
Client code:
binaryWriter.Write(10);
binaryWriter.Write(20);
Server code:
int value1 = binaryReader.ReadInt32(); //10
int value2 = binaryReader.ReadInt32(); //20