The problem might be that the slider is updating the value to fast.
But I am not sure. What can I do to presuppose that only one value is sent at a time?
First and foremost I would answer, how does a float value come out as this:
It seems perhaps you are failing to put newlines after each output and several reading strings are being concatenated into one string. That ain’t right!
Nothing above produces a new line. Have you tried adding a newline?
This “cheap and cheerful” method of blasting raw text out a port that you are using might ultimately be workable, but a more-sustainable method is to prepare a class with the information you want, serialize it out with JSON, and then read it back in on the other side.
ok?, i now know what json serializationis is and how to serialize sth. (i never worked with it before).
But I don’t quite understand how to use it.
It would be very nice if you could write an example or link me to one.
The internet has PLENTY of JSON tutorials. Don’t reach for it if you don’t want to. My only point is that blasting unstructured text data from one computer to another this way is going to constantly require maintenance as you extend it to contain more data, or encounter whitespace formatting issues such as what you’re seeing above. Structuring the data would help in this regard.
No, it is your issue not designing your protocol in a robust way. You use a streaming protocol which does not send messages but an endless stream of data. If you want to send messages across a network stream you have to implement your own application layer protocol. If you want to use a text based protocol, using newline character or some other terminating character like Kurt suggested would be an option. However if you just send out an endless stream of floating point values, using a normal binary representation would make more sense since every float has 4 bytes so it’s way easier to seperate out the individual values.
Though it seems you have very little experience with networking. I would highly recommend to look up some basic networking examples. Over here I posted an example of a standalone server application which sends out png images to all clients. It uses a very simply naive protocol. It just sends out the image size as a 4 byte integer followed by the image. The receiving side of course knows this protocol and reads one integer and then reads that amount of bytes from the stream. This does work because TCP is a reliable protocol, so no data is dropped and we can ensure that the images come in one after another.