Counting words in a stream
<p>I was asked this question in an interview, if an application is transmitting some text, for e.g a client makes an http call and in the body of post has a text message, then how does the server side know when it has received the complete message from start to end. In other words, if you wanted to count the number of words in this stream of text, how can you do that? Normal word counting is done through a state machine sort of approach, where you keep track of spaces and increment only once for a space between 2 words. Is counting words from a stream any different ? How ? </p>
