tags:

views:

77

answers:

1

hi everyone,

i'm making a client for pop3 and somehow i can't figure out how to handle multiline responses. There is no difference in the response from server whether it is single or multiline, it always ends with CRLF (considering the usual case) so how do I know if I should call recv() once more?

+3  A: 

Responses that can span more than one line (such as the contents of an email) are identified as such in the POP3 RFC.

The last line of a multi-line response just contains a dot "."

So look for "\r\n.\r\n"

That last line is a termination mark. It's not part of the actual message.

Alexandre Jasmin
yea but the first doesn't and I don't know if the incoming response is going to continue or not. I mean i don't know if it's going to be just a single line or more
stupid_idiot
@stupid_idiot just keep calling recv() until you see that end marker. You can't know in advance when it'll end.
Alexandre Jasmin
Well, the way I understood Alexandre, if there's only one line, then the first is also the last - and should thus end with a dot. From that it kinda follows, that, if it doesn't end with a dot, it's not the last one, and thus not the only one. `<reads it again>` Well, that certainly seems logical. Where's the problem, stup... Oh, I see. Never mind.
sbi
oh..heh, now i get it, i misunderstood the description on rfc. mkay.. thx a lot and sry for bothering you.
stupid_idiot