Dokleiłem i bez zmian, nadal nic nie jest zwracane.
Całość kodu programu:
namespace client1
{
public class TcpClient1
{
private static void Main()
{
TcpClient KlientTCP = new TcpClient();
try
{
KlientTCP.Connect(IPAddress.Parse("xxx.xxx.xxx.xxx"), 1001);
String message=(char)2 + "01" + (char)13 + '{' + (char)135 + '}' + (char)13 + (char)10;
Byte[] komunikat = System.Text.Encoding.ASCII.GetBytes(message);
// Get a client stream for reading and writing.
// Stream stream = KlientTCP.GetStream();
NetworkStream stream = KlientTCP.GetStream();
// Send the message to the connected TcpServer.
stream.Write(komunikat, 0, komunikat.Length);
Console.WriteLine("Sent: {0}", message);
// Receive the TcpServer.response.
// Buffer to store the response bytes.
komunikat = new Byte[256];
// String to store the response ASCII representation.
String responseData = String.Empty;
// Read the first batch of the TcpServer response bytes.
Int32 bytes = stream.Read(komunikat, 0, komunikat.Length);
responseData = System.Text.Encoding.ASCII.GetString(komunikat, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
// Close everything.
stream.Close();
KlientTCP.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: {0}", e);
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
Console.WriteLine("\n Press Enter to continue...");
Console.Read();
}
}
}
Oczywiście w miejsce xxx.xxx.xxx.xxx w KlientTCP.Connect(IPAddress.Parse("xxx.xxx.xxx.xxx"), 1001); wstawiam odpowiedni adres IP wagi.
Konsola wygląda w sposób następujący: