Oh, that's usually part of the protocol. How would you tell that you've got the end of the message if you read a sequence of messages from a file? (Note: rhetorical question -- this is meant for you to think about the problem you are having so you can solve it yourself.)
Note that .read(N) reads at least one but at most N bytes, blocking at most once, so maybe you can do something with that. On Fri, Jul 31, 2015 at 6:40 PM, Wellington Cordeiro <willy123...@gmail.com> wrote: > I'm not sure I entirely follow though, if I don't know the size of the > response ahead of time, how will readexactly(N) help me? > > On Friday, July 31, 2015 at 10:12:29 AM UTC-6, Guido van Rossum wrote: >> >> Perhaps better to use readexactly(N), which raises EOF instead of >> returning fewer than N bytes if it hits EOF early. >> >> On Fri, Jul 31, 2015 at 5:02 PM, Victor Stinner <victor....@gmail.com> >> wrote: >> >>> 2015-07-31 6:56 GMT+02:00 Luciano Ramalho <luc...@ramalho.org>: >>> > It seems to me you can't use .read() with no arguments to read data >>> > that is not line-oriented and is not the whole transmission either. >>> > You must use .read(N), where N is a number of bytes. Then you parse >>> > what you get and decide on a suitable value of N for the next read. >>> > Rinse and repeat. >>> >>> Exactly. >>> >>> Victor >>> >> >> >> >> -- >> --Guido van Rossum (python.org/~guido) >> > -- --Guido van Rossum (python.org/~guido)