ImageVerifierCode 换一换
格式:DOCX , 页数:18 ,大小:766.55KB ,
资源ID:30463798      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/30463798.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(北邮国际学院互联网应用cousework.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

北邮国际学院互联网应用cousework.docx

1、北邮国际学院互联网应用couseworkPop3The 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 functio

2、ns 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, r

3、equire 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-mailsWhen user enters the corresponding command, the program can display the number or the list of the E-mails orderly on screen.2.Display the co

4、ntent of mailsAllow users to choose the mail they want to check by providing two choices - download and print it on screen.3.Delete the mailsAllow users to choose the mail they want to delete and delete it from the mailbox.4.search text in mailsWhen user enters the texts they want to search, the pro

5、gram will display the file names of the files contain it.5.Display the mails by subjectDisplay 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

6、() 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

7、 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 t

8、hree 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.voi

9、d 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 ca

10、lled 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 rec

11、eived 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

12、 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 a

13、ccomplish the display by subject task. Overall flowchartDesign of data structureIn the program, there are eleven global varibles:FILE_MODE 0644- Define the mode of opening a file. PORT 110- Port number for the TCP connection. char *IP- hold the server s IP address.msg250- hold the received comd2200=

14、USER ,PASS , command5200=STATn,LISTn,RETR ,DELE QUITn, mail250; int recvMsgSize,sock,qt=0,dl=0;int main():First, I use a while loop, in which the IP resolve and log on tasks are implemented. A global varible ip in int type is used to control the loop. It is set to 0 at the beginning. When the functi

15、on int getIP() successfully convert the received pop3 server domain name into the IP address, it will return 1 to the varible ip , the ip will be set to 1 so that the while loop can be ended. Then, if the expression strstr(msg,+OK)!=NULL is true, the function void logOn() and void logged() will be c

16、alled consequently to finish the other two tasks, if it is false, the socket will be closed and the program will be ended. int printMail();It is called in function void logged() to print and download the E-mail. As the flow chart shows, the program first provide two choices for the user - 1 and 2. I

17、f the user enter 1, a file name is required from the user in order to create a file holding the mail. If the choice is 2, the mail will be printed out on the screen. To receive the mail properly, a while loop is used which is controlled by the variable i in int type. It is set to zero at the beginni

18、ng. Then 250 characters are receivedin the global variable char mail250 each time , if the length of mail is less than 250, the function int chkEnd() is called to check wether it reaches the end of the mail. If it is the end, the function will return 1 , which is given to i to end the while loop. in

19、t 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. As the flowchart shows, when the user s command is stat, ls, find or sort, the

20、variable int choice will be set to 0, 1, 5 and 6 orderly. When the command is get or dele, the program will require the user to enter the number of the mail they want to get or delete, then set choice to2 and 3 correspondingly. If the entered command is quit, the global variable qt is set to 1 and t

21、he choice is set to 4. If the command is not match to all the command mentioned above, the choice is set to 7. At last, return choice.void logOn()It is called in function main() and used for guiding the user log on to the E-mail. The function int mygetch() is called in it to get each character impli

22、citly.As the flowchart shows, a while loop is used to allow the user enter the username and password repeatedly. It first require a username from the user. Then generate and send the pop3 command out. If the strstr(msg,+OK)!=NULL, then require the user enter the password. To make the password entere

23、d implicitly, the function int mygetch() is called in a for loop. If the received character is n, the for loop is ended if not print *. Then, send the password in pop3 style, if the strstr(msg,+OK)!=NULL, print out the received message and step out the while loop. void logged() :It is called in func

24、tion main() to provide 7 common functions of the E-mail to the user. A while loop is used in it to allow the user repeating choose the command. The global variable qt in int type is used to control the while loop. It is set to 0 at the beginning. In the loop, the program first provide some informati

25、ons about how to choose different commands to realize different functions. Then, it calls the function makeChoice() by passing the string got from user s to it, the return value of the function is given to a int type variable n. According to the value of n, corresponding pop3 command is sent out and

26、 corresponding functions are called. The while loop will continue to run unless the entered command from the user is quit. Because when the string passed in the function int makeChoice() is quit, the global variable qt will be set to 1 so that the while loop can be ended. sortSub()it is called by th

27、e function logged() to accomplish the display by subject task. This function is written on the condition that the file name are all numbers so that a for loop can be adopted to open each of them to sort their subjects. An array of strings - char s7100 is defined to hold the subject of each file in o

28、rder to sort the subjects in the second for loop. A variable fs in FILE * type is defined to set up a file steam. In the first for loop, I didin t set a condition to control the loop so that it can continue running until a failure of openning the file accurs. Each time in the loop, I use the functio

29、n snprintf to convert the variable n in int type to a string stored in variable j and open the file named m. If the fs is NULL, break to step out of the loop to do the second for loop. If not, enter a while loop, in which I use fgets to read a line in the file each time. If the first character in th

30、e line is S, get the remaining part after the string Subject by using the strtok function and copy it to si. Then close the file steam and break the while loop. In the second for loop, I use bubble sort method to sort the subjects and print them out. To compare the subjects, the function strcmp is u

31、sed. void srch()This function is written on the condition that the file name are all numbers. First, the program prompt a message to ask the user enter the text they want search and save the text into the variable content in char type. Then, a for loop is adopted to open each file to find the text.

32、In the loop, I first use function snprintf(j, 2, %ld, i) to convert the variable i in unsigned long type to j in char type. Then open the file named j, if the file can not open, print Done! and break the loop, if not, read the file into the variable buf in char. Use the function strstr to find the text in the buf. If the expression - strstr(buf,content)=NULL is true, print j is none where j is the file na

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1