python: Is there anyway to read messages from a tcp port without knowing the sent message size?
<p>I'm trying to do write a python script that should work as a tcp server. I receive messages of different sizes from a client whose message format cannot be changed, so my server script is the one that, somehow, should get adapted to the received messages. Together with this, the server can't send back any kind of ack to the client. The server must just receive the variable size messages and afterwards process them. </p>

<p>Is there any way to do so?</p>

<p>TCP is a data stream protocol which means that there are no inherent message boundaries. The concept of a message can only be defined by the application. This is typically done by defining a message boundary or by prefixing the message with its size. Since the message is thus defined at the application level you will not be able to read a message with a TCP level command only (i.e. plain socket read). Instead your application must read and then interpret the data stream to find out where the message starts and ends.</p>

python tcp