北邮国际学院互联网应用cousework
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Pop3
The pop3 client-side program is intend to fulfil the following three main tasks:
1.Resolve the pop3 server domain name and convert it into IP address to establish a TCP connection between the client and the server.
2.Guide the user log in the E-mail .
3.Provide common functions of E-mail for the user, including get the number and list of the E-mails, display the content of mails,delete the mails, search text in mails and display the mails by subject.
Specifically speaking, the log-in process 's requirements:
After establishing the connection with the server successfully, require user name and password from the user and check whether they are valid.
The five common functions ' requirements are:
1.Get the number and list of the E-mails
When user enters the corresponding command, the program can display the number or the list of the E-mails orderly on screen.
2.Display the content of mails
Allow users to choose the mail they want to check by providing two choices --- download and print it on screen.
3.Delete the mails
Allow users to choose the mail they want to delete and delete it from the mailbox. 4.search text in mails
When user enters the texts they want to search, the program will display the file names of the files contain it.
5.Display the mails by subject
Display the E-mail by subject, meaning files with the same subjects will be grouped together.
Therefore, I decompose the whole program into three parts by writing two other functions apart from main() -- void logOn() and void logged(). The first task is implemented in main() by calling the function int getIP(); the second task is implemented in the function void logged(); the last one is implemented in the function void logOn(). Since there are too many functions need to be achievedin the logOn() , five other functions are called in it, they are: int printMail(); int chkEnd(int); int makeChoice(char*); void srch(); void sortSub().
Thus, the whole program is decomposed into 10 modules (10 functions ) as shown in the below chart:
int main(): the main function is where a program starts execution; it calls three functions in it: int getIP(), void logOn() and void logged().
int getIP(char []): it is used to convert the received pop3 server domain name to IP address. When called in main() function, an argument in char [] type will be passed to it and then converted to IP address in dotted decimal notation.
void logOn() : it is called in function main() and used for guiding the user log on to E-mail. The function int mygetch() is called in it to get each entered character implicitly.
void logged() : it is called in function main() to provide 7 common functions of E-mails to the user.
int mygetch(): it is called in function void logOn() to make the entered character from the user invisible.
int printMail(): it is called in function void logged() to print and download the E-mail. Function int chkEnd(int ) is called by it to check the end of the message.
int chkEnd(int ): it is used to check wether the received message from the server has reached to the end. When called in the function int printMail(), the length of the received in int type is passed to it. It will then return 0 or 1 to indicate whether it is the end of the mail.
int makeChoice(char *a): it is used to check which command does the user input. When called in the function logged(), the user ' s command in char * type is passed to it. Then, it return the corresponding integer in int type.
void srch(): it is called by the function logged() to accomplish the " search by text " task.
void sortSub(): it is called by the function logged() to accomplish the " display by subject " task.
Overall flowchart