Trying to send a string containing a number of newline characters between words using TCPclient and C# where the newline characters needs to stay intact…
Working c++ example is here:
TCPClient->IOHandler->DefStringEncoding = enUTF8;
TCPClient->IOHandler->WriteLn("write text");
TCPClient->IOHandler->WriteLn("Test\n\n\nTest");
With this code the string shows up in the servers textfield the way I want: Test\n\n\nTest
But when trying c#:
clientStreamWriter.WriteLine("write text");
clientStreamWriter.WriteLine("Test\n\n\nTest");
This string shows up in the server textfield as: Test
Then the server returns a unknown command response… Seems as the StreamWriter breaks the string at the newline character and sends the rest as a new string and the server expects a new command.
How can I prevent this from happening? I have no idea what the server code is and writing in c++ is not an option for me 🙂
The problem is with your server protocol; you’ll need to change the server to fix it. You need message framing.