nyjcr wrote:
the problem is that the string comes with "empty" characters at the end.
No, the string doesn't come with any empty characters. The problem is that you get the length of the actual data, but then you just ignore that and convert the entire buffer into a string. The unused part of the buffer just happens to be filled with zeroes. Only convert the actual data: dataReceived = System.Text.Encoding.ASCII.GetString(input, 0, bytesReceived);
Despite everything, the person most likely to be fooling you next is yourself.