网络编程技术实验指导书

上传人:ni****g 文档编号:470269099 上传时间:2022-12-23 格式:DOC 页数:11 大小:171KB
返回 下载 相关 举报
网络编程技术实验指导书_第1页
第1页 / 共11页
网络编程技术实验指导书_第2页
第2页 / 共11页
网络编程技术实验指导书_第3页
第3页 / 共11页
网络编程技术实验指导书_第4页
第4页 / 共11页
网络编程技术实验指导书_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《网络编程技术实验指导书》由会员分享,可在线阅读,更多相关《网络编程技术实验指导书(11页珍藏版)》请在金锄头文库上搜索。

1、 网络编程技术实验指导书董黎刚信息与电子工程学院浙江工商大学10/3/2006 2:24:00 PM Content1. Operation of Linux (操作性)11.1 Purpose11.2 Content11.3 Hints22. C Programming Practice(设计性)32.1 Purpose32.2 Content32.3 Grading33. Simple Socket Programming(验证性)43.1 Purpose43.2 Content43.3 Hints44. Concurrency Socket Programming(验证性)54.1 Pu

2、rpose54.2 Content54.3 Hints55. Windows Socket Programming(验证性)65.1 Purpose65.2 Content65.3 Hints66. Advanced Socket Programming (设计性)76.1 Purpose76.2 Content76.3 Grading8Experiments of Network Programming Last updated: 10/3/20061. Operation of Linux (操作性)Name: No.: Class: Grading:1.1 PurposeReview t

3、he operation of Linux, in particular shell commands (bash).1.2 ContentEach student is required to finish all of the following tasks. Part I Programming 1) Use “vi” to construct a program “helloworld.c” that can print“hello world”. Compile and run it. (hint: gcc helloworld.c, ./a.out)Part II File/Dir

4、ectory2) Make a new sub-directory in current directory, then move “helloworld.c” into this new sub-directory. (hint: mkdir source, mv old_file new_file)3) Change the access permissions of “helloworld.c” to -rw-r-xrw-. (hint:chmod 656 helloworld.c)4) Find a file named “emacs” in hard disk. (hint: fin

5、d / -name emacs)5) Make a hard link, which is called “helloworld1.c”, of “helloworld.c”. (hint: ln old_file new_file); 6) Make a symbolic link, which is called “helloworld2.c”, of “helloworld1.c”. Then remove helloworld1.c. (hint: ln s old_file new_file) Check the output of “ls l” to compare the har

6、d link and soft link.7) Make a copy of “helloworld.c”. The new file is “helloworld3.c”. (hint: cp source_file destination_file) 8) Archive and compress all the files inside a sub-directory. (hint: tar cvf new_file.tar *, gzip old_file)Part III Text9) Show the first 10 line of helloworld.c in reverse

7、 order. (hint: head helloworld.c | sort -r)10) Print the number of bytes, words, and lines of helloworld.c to a file called “info.txt”. (hint: wc helloworld.c info.txt)11) Merge helloworld.c and info.txt to a new file “helloworld.txt”. (hint: paste helloworld.c info.txt helloworld.txt)12) Print colu

8、mn 3-5 of “helloworld.c”. (hint: cut c3-5 helloworld.c)13) Remove “/home/your_name/source”. (hint: rmdir, rm)Part IV Process14) compare the difference among “ps”, “ps f”, and “ps ef”. 15) execute “top” to show the most active processes.Part V I/O Devices 16) Find the free space size in hard disks an

9、d usage size of /usr/src. (hint: du, df)Part VI Networking17) Find the IP address of the local host. (hint: ifconfig)18) Change the IP address of the localhost. (hint: ifconfig eth0 192.168.2.2 up Or change /etc/sysconfig/network-scripts/ifcfg-eth0)Part VII System Management19) Find the version of L

10、inux kernel and host name in the local host. (hint: uname a)20) Set a regular variable called “var1” and an environment variable “var2”. You can assigned any value. (hint: var1=10, export var2=3, 分别用set, env来查看)21) Find the memory and cpu usage information of this local host. (hint: cat /proc/cpuinf

11、o, cat /proc/meminfo) 22) Find the .h file containing the definition of struct sockaddr_in in /usr/src/. (hint: grep r “struct sockaddr_in ” /usr/src/* )1.3 Hints1) 先理解命令的含义,再运行试验。如果你想了解是否有完成某项工作的命令,可以使用“apropos 关键词”;如果你想了解某个命令的细节(比如选项),可以使用“man ls”, “ls help” (以ls为例)。如果你想知道某个命令的文件在哪个目录里,可以使用“wherei

12、s ls”, “which ls” (以ls为例)。2) 命令执行完,要检查一下是否执行正确,比如用“ls l”检查是否产生了新的文件3)命令执行失败的常见错误有:a) 名字敲错;b) 命令和选项或执行对象之间没有空格;c)文件确实不在你所预想的那个目录里,这可以用“ls l”来检查;d)文件不在缺省路径里,你需要指定文件的路径。4) 用Ctrl-C强行退出正在运行的命令2. C Programming Practice(设计性)Name: No.: Class: Grading:2.1 PurposeReview the knowledge of C programming, in part

13、icular operation of structure, pointer, memory, file, etc. It is necessary before learning network programming.2.2 ContentEach student is required to construct a small information management program for managing student records (e.g, No., name, age, scores, hometown) with the following constraint.1)

14、 Use a binary file (NOT a text file) to store student records. 2) You can dynamically edit (e.g., add, remove, and show) student records. 3) You must use linked list(链表), pointer(指针), files(文件), structure(结构), dynamic allocation of space(动态分配空间).2.3 GradingContentDetailScore1.Function of programs(30

15、)(1)记录用结构表示,至少包含字符串(如名字)和整型(如年龄)(5)(2)用链表来动态保存记录,并能以命令行或者菜单形式增加(5)、删除(5)和查询(5)内容。如果用数组最多得5分(3)用二进制文件永久保存记录,并能在程序开始运行时读取文件内容(5),在程序运行结束前保存到文件(5)2.Quality of programs(30%)(1)用大括号和缩进来清楚地显示程序结构。(提示:按一次tab键产生一个缩进)(5)(2)各函数有功能说明和参数说明(5)(3)每个源程序文件都有说明(比如本程序功能,作者,包含哪些函数)(5)(4)每个函数长度不超过100行(5)(5)函数、变量取名前后一致并容易理解(5)(6)对不容易理解的常量、

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 机械/制造/汽车 > 工业自动化

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号