Network TCP total length

I am testing a simple TCP server/client app using the Network support on mac os x. It basically works well except when the server sends a lot of data (definition of "a lot" is that the amount of data exceeds the maximumLength value in the connection.receive call). In this case the client will receive multiple segments (each of which has less than or equal maximumLength value). For example if the maximumLength is set to 30000 and the server sends 100000 bytes, the client receive loop will get around 4 segments each of which has length <= 30000.

My question is: is there some information that the client can examine from the connection after a receive to determine that more data is available?

Yes, generally you should keep calling receive until both isFinal is true on the contentContext and isComplete is set to true. Here, "final" means that this is the last message that will appear on this connection, which is always true for a connection with just TCP, and "complete" means that this is the last chunk of data for this particular message.

So you're all done when you've received the last bit of content from the last (and in this case only) message.

In any other situation where error is nil, there's potentially more data to be read and you should keep calling receive.

Network TCP total length
 
 
Q