------------------------- Week 07 Notes for CST8165 ------------------------- -Ian! D. Allen - idallen@idallen.ca Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) ------------------- INDEX to this file: - notes on current and previous assignments: GDB - this week: SMTP client in Perl Net::Telnet Readings in the SMTP RFC ------------------- * Debugging C language using gdb - new links on home page include a GDB tutorial http://www.cs.rochester.edu/u/srini/csc172/gdb.html "If you have eight hours to cut down a tree, it is best to spend six hours sharpening your axe and then two hours cutting down the tree." - gdb reference card: http://sources.redhat.com/gdb/download/onlinedocs/refcard.ps.gz - the full manual http://sources.redhat.com/gdb/download/onlinedocs/gdb.html - debugging multi-process programs (fork): http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gdb/processes.html http://www.delorie.com/gnu/docs/gdb/gdb_26.html http://www.cs.toronto.edu/~maclean/csc209/ddd-gdb-children.html - gdb normally follows the parent; to debug a child process (gdb) set follow-fork-mode child You can put these kinds of init commands in file .gdbinit Q: If you overflow an auto variable buffer in main() and then return, your program faults and dies. If you call exit(), the program doesn't die. In both cases, the program is terminating. Why does "return" fault and the other exit() cleanly? * Using the Perl module Net::Telnet SMTP Reference: ftp://ftp.rfc-editor.org/in-notes/rfc2821.txt - easiest way to implement an SMTP client Reference: "man Net::Telnet" or see notes file perl_net_telnet.txt http://www.perlfect.com/articles/telnet.shtml http://search.cpan.org/search?module=Net::Telnet http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm - see the Perl examples posted in the course notes for Lab 4 SMTP Client Template for Lab 4: smtpclient_v1.pl Reading STDIN with Perl: read_stdin.pl Automated testing: testplanscript2.txt Test output: test_out2.txt Q: T/F The Net::Telnet module already converts LF to CR+LF on output to the remote server and converts CR+LF to LF in input from the server. (Look for the explanation under "binmode") * Reading RFC 2821 - the SMTP protocol The RFC is the final word on the protocol. Q: T/F The space following the three-digit SMTP respose code is mandatory and all clients MUST look for it, failing if it is not found. (RFC Section 4.2) Q: How must an SMTP client handle new response codes that it doesn't recognize? (RFC Section 4.2, 4.3.2) Q: T/F SMTP clients can figure out how to proceed based on just the first digit of an SMTP reply code; they can usually ignore the rest. (RFC Section 4.2, 4.3.2) Q: T/F You can queue up and send multiple commands to an SMTP server without waiting for any responses. (RFC Section 4.3.1) Q: Looking at RFC Section 4.3.2, there are three codes that might be returned by an SMTP server "if the corresponding unusual circumstances are encountered". What are these three codes? Q: Looking at RFC Section 4.3.2, list the possible success code(s) that might be returned after sending EHLO to the server. List the possible error codes. (Include the three codes from the previous question.) Q: Looking at RFC Section 4.5.2, how must clients handle message lines that start with a period? Q: What is the maximum length of an email address (local-part plus domain), as passed through the SMTP protocol? (RFC Section 4.5.3.1) Q: How long may an SMTP server delay before issuing the initial 220 Message greeting? (RFC Section 4.5.3.2) Q: Based on experience, what is the suggested policy for retrying failed attempts at sending a message? (RFC Section 4.5.4.1) Q: Should programs attempt to relate the MAIL and RCPT (envelope) email addresses with the addresses (that may be) present in the headers of the message body? (RFC Section 7.2)