I have a sensor that has an ip and port 192.168.2.44:3000.
I used the herculas to connect to the device ,as you can see in the picture :
enter image description here
I need to implement this software in c# ,so i write this code :
private static void Main(string[] args)
{
try
{
byte[] buffer = new byte[2048]; // read in chunks of 2KB
int bytesRead;
var listener = new TcpListener(IPAddress.Any, 3000);
listener.Start();
NetworkStream network_stream;
StreamReader read_stream;
StreamWriter write_stream;
var client = listener.AcceptTcpClient();
network_stream = client.GetStream();
read_stream = new StreamReader(network_stream);
write_stream = new StreamWriter(network_stream);
write_stream.WriteLine("00010002000B0300010004C380");
write_stream.Flush(); //veriyi gönderiyor
string gelen;
gelen = read_stream.ReadLine();
Console.WriteLine(gelen);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
When i put a breakpoint the gelen = read_stream.ReadLine();
returns null
the final code :