How can i check a response from a server? Ex: Say i log onto an SMTP server. I get this response: "220 mail.smtp.com SendMail v5.0 Ready" My program would say: "Helo localhost" The server would say: "250 Hello, 127.0.0.1 pleased to meet you." Etc... So my question is how can i check for the 220 & 250??? That way, once the program has "seen" the response from the server, then it can continue on with the next part of the code. Know what i mean??? Any help is appreciated. Later for now. Thanks! Nok.
You can store received data in a buffer and every time data is added, check if the buffer contains a full line (CR, LF or CRLF terminated). If not, just wait for more data. If yes, examine the response code by taking the first three bytes from the buffer and then proceed with your code according to the response code (after you've deleted the line in the buffer). hope this helps, Thomas
Here's some code I used for my HTTP server, maybe it's of some use to you:
;RECEIVEBUFFERSIZE equ XXXXXXXX ;max buffer size ;ReceivedData db RECEIVEBUFFERSIZE dup (?) Received data buffer ;CurrentBufferSize dd ? Current number of bytes in buffer ; ; ---- traces buffer for lines (CR/LF/CRLF) and calls a routine for every line ---- ; ---- returns 1 on success --- UpdateBuffer proc uses edx ecx esi ebx xor esi, esi @ub_trymore: mov edx, offset ReceivedData mov ecx, edx add ecx, CurrentBufferSize ;---------- Scan for CR/LF------------ .WHILE (edx
Great! Thanks Thomas!!! I owe ya one.