Repeating IMAP Responses

Can someone explain the behavior of the responses of the IMAP server? When I send one command, the answer meets the expectations:

C: A0001 FETCH 10 (BODY[HEADER.FIELDS (SUBJECT)])
S: * 10 FETCH (BODY[HEADER.FIELDS (SUBJECT)] {21}
   Subject: FW: test

   )
   A0001 OK FETCH completed.

But if I send several commands one by one, the behavior of the answers is unclear:

C: A0001 FETCH 10 (BODY[HEADER])
S: * 10 FETCH (BODY[HEADER] {1632}
   ...
   A0001 OK FETCH completed.
C: A0002 FETCH 10 (BODY[HEADER.FIELDS (SUBJECT)])
S: * 10 FETCH (BODY[HEADER] {1632}
   ...
   A0001 OK FETCH completed.
C: A0003 FETCH 10 BODY[TEXT]
S: * 10 FETCH (BODY[HEADER.FIELDS (SUBJECT)] {21}
   Subject: FW: test

   )
   A0002 OK FETCH completed.

Why are the answers repeated? And how to fix it? The code

+4
source share
1 answer

The problem was that the write to the ssl stream occurred in a read loop from the ssl stream.

+3
source

Source: https://habr.com/ru/post/1693892/


All Articles