计算机网络课程设计.docx
《计算机网络课程设计.docx》由会员分享,可在线阅读,更多相关《计算机网络课程设计.docx(19页珍藏版)》请在冰豆网上搜索。
计算机网络课程设计
内蒙古科技大学
本科生课程设计论文
题目:
网上聊天程序
学生姓名:
学号:
专业:
计算机科学与技术
班级:
指导教师:
内蒙古科技大学课程设计任务书
课程名称
计算机网络课程设计
设计题目
网上聊天程序
指导教师
时间
2012.12.24-2013.1.5
一、设计要求
1、学习套接字编程
2、实现基于TCP的客户端服务器的连接
3、读懂源码的基础上修改
二、设计资料及参数
《计算机网络》实训为计算机科学与技术专业教育平台的专业实践课程。
通过本实训,使学生在对计算机网络技术与发展整体了解的基础上,通过编写计算机程序模拟网络通信的某些功能,使学生理解并掌握网络通信系统的基本工作原理及工作过程.
三、设计要求及成果
1、实现客户端和服务端的聊天
2、个性图形界面附录
3、核心程序清单
四、进度安排
Ø资料查阅与讨论(1天)
Ø案例分析(1天)
Ø系统分析(2天)
Ø网络具体配置与测试(4天)
Ø编写实训说明书和答辩(1天)
五、评分标准
1.选题合理、目的明确(10分)
2.设计方案正确,具有可行性创新性(20分)
3.设计结果(20分)
4.态度认真、学习刻苦、遵守纪律(15分)
5.设计报告的规范化、参考文献充分(10分)
6.答辩(25分)总分(100分)
六、建议参考资料
《计算机网络实验指导书》,张建忠,北京:
清华大学出版社,2005
《计算机网络教程题解与实验指导》。
黄叔武,北京:
清华大学出版社,2006
目录
1、设计背景-3-
2、需求分析-3-
3、软件设计框图-3-
1、主要控件:
-3-
2、流程图:
-4-
4、核心程序清单-5-
5、测试-13-
1、程序界面:
-13-
2、启动并运行程序:
-14-
7、参考文献-16-
1、设计背景
随着计算机网络日新月异的发展,人们的交流方式越来越多,传统的交流方式,如:
信件、电报、电话等已经难以满足人们的交流要求,在互联网上即时的和好友取得联系,已经成为当今社会人们主流的联系方式。
因此,两台计算机之间进行即时通讯、发送文件等交流方式已经成为必然潮流。
2、需求分析
现在虽然出现了QQ等聊天工具,然而QQ等聊天工具虽然方便、实用,但是,娱乐功能太多,有很多吸引人的娱乐功能,从一定程度上来说,是一种娱乐工具,不能作为用于即时通讯、文件共享的专用工具。
目前,用于实现单一的即时通讯、文件共享的软件实在太少,而且,它们中大部分都是绝对的C/S模式,对远程服务器有非常大的依赖性,没有彻底实现点对点的交流。
为此,我决定开发一个专用于实现两台计算机之间即时通讯的软件,以方便两台计算机之间信息的交流。
避免了服务器忙或与服务器无法连接时,浪费过多时间用于和服务器建立连接。
因此,这个软件是极具适应性和实用性的即时通讯软件。
3、软件设计框图
1、主要控件:
控件类型
控件ID
主要属性设置
用途
RichTextBox
rtbContent
BorderStyle:
None
显示聊天信息
rtbSend
BorderStyle:
None
输入信息
TextBox
textIP
默认
输入对方主机
textName
默认
输入昵称
Button
buttonClear
清空聊天记录
buttonSend
发送信息
buttonClose
退出
Timer
Timer
Interval:
1000
定时更新受到的信息
2、流程图:
4、核心程序清单
[html]viewplaincopy
1//文件Program.cs
2usingSystem;
3usingSystem.Collections.Generic;
4usingSystem.Linq;
5usingSystem.Threading.Tasks;
6usingSystem.Windows.Forms;
7
8
9namespaceOO
10{
11staticclassProgram
12{
13///
14///应用程序的主入口点。
15///
16[STAThread]
17staticvoidMain()
18{
19Application.EnableVisualStyles();
20Application.SetCompatibleTextRenderingDefault(false);
21Application.Run(newmainForm());
22}
23}
24}
25
26//文件Form1.Designer.cs
27namespaceOO
28{
29partialclassmainForm
30{
31///
32///必需的设计器变量。
33///
34privateSystem.ComponentModel.IContainercomponents=null;
35
36
37///
38///清理所有正在使用的资源。
39///
40///如果应释放托管资源,为true;否则为false。
41protectedoverridevoidDispose(booldisposing)
42{
43if(disposing&&(components!
=null))
44{
45components.Dispose();
46}
47base.Dispose(disposing);
48}
49
50
51#regionWindows窗体设计器生成的代码
52
53
54///
55///设计器支持所需的方法-不要
56///使用代码编辑器修改此方法的内容。
57///
58privatevoidInitializeComponent()
59{
60ponents=newSystem.ComponentModel.Container();
61System.ComponentModel.ComponentResourceManagerresources=newSystem.ComponentModel.ComponentResourceManager(typeof(mainForm));
62this.rtbContent=newSystem.Windows.Forms.RichTextBox();
63this.rtbSend=newSystem.Windows.Forms.RichTextBox();
64this.textIP=newSystem.Windows.Forms.TextBox();
65this.textName=newSystem.Windows.Forms.TextBox();
66this.butClear=newSystem.Windows.Forms.Button();
67this.butClose=newSystem.Windows.Forms.Button();
68this.butSend=newSystem.Windows.Forms.Button();
69this.timer=newSystem.Windows.Forms.Timer(ponents);
70this.labelIP=newSystem.Windows.Forms.Label();
71this.labelName=newSystem.Windows.Forms.Label();
72this.SuspendLayout();
73//
74//rtbContent
75//
76this.rtbContent.BackColor=System.Drawing.Color.Silver;
77this.rtbContent.BorderStyle=System.Windows.Forms.BorderStyle.None;
78this.rtbContent.Location=newSystem.Drawing.Point(9,82);
79this.rtbContent.Name="rtbContent";
80this.rtbContent.Size=newSystem.Drawing.Size(567,232);
81this.rtbContent.TabIndex=0;
82this.rtbContent.Text="";
83//
84//rtbSend
85//
86this.rtbSend.BackColor=System.Drawing.Color.Silver;
87this.rtbSend.BorderStyle=System.Windows.Forms.BorderStyle.None;
88this.rtbSend.Location=newSystem.Drawing.Point(9,339);
89this.rtbSend.Name="rtbSend";
90this.rtbSend.Size=newSystem.Drawing.Size(567,47);
91this.rtbSend.TabIndex=1;
92this.rtbSend.Text="";
93//
94//textIP
95//
96this.textIP.BackColor=System.Drawing.Color.Silver;
97this.textIP.BorderStyle=System.Windows.Forms.BorderStyle.None;
98this.textIP.Location=newSystem.Drawing.Point(98,322);
99this.textIP.Name="textIP";
100this.textIP.Size=newSystem.Drawing.Size(152,16);
101this.textIP.TabIndex=2;
102//
103//textName
104//
105this.textName.BackColor=System.Drawing.Color.Silver;
106this.textName.BorderStyle=System.Windows.Forms.BorderStyle.None;
107this.textName.Location=newSystem.Drawing.Point(53,7);
108this.textName.Name="textName";
109this.textName.Size=newSystem.Drawing.Size(150,16);
110this.textName.TabIndex=3;
111//
112//butClear
113//
114this.butClear.BackColor=System.Drawing.Color.Silver;
115this.butClear.FlatAppearance.BorderSize=0;
116this.butClear.FlatStyle=System.Windows.Forms.FlatStyle.Popup;
117this.butClear.Location=newSystem.Drawing.Point(342,395);
118this.butClear.Name="butClear";
119this.butClear.Size=newSystem.Drawing.Size(87,27);
120this.butClear.TabIndex=4;
121this.butClear.Text="清屏";
122this.butClear.UseVisualStyleBackColor=false;
123this.butClear.Click+=newSystem.EventHandler(this.butClear_Click);
124//
125//butClose
126//
127this.butClose.FlatAppearance.BorderColor=System.Drawing.Color.Silver;
128this.butClose.FlatAppearance.BorderSize=0;
129this.butClose.FlatStyle=System.Windows.Forms.FlatStyle.Popup;
130this.butClose.Location=newSystem.Drawing.Point(342,432);
131this.butClose.Name="butClose";
132this.butClose.Size=newSystem.Drawing.Size(87,27);
133this.butClose.TabIndex=5;
134this.butClose.Text="关闭";
135this.butClose.UseVisualStyleBackColor=true;
136this.butClose.Click+=newSystem.EventHandler(this.butClose_Click);
137//
138//butSend
139//
140this.butSend.BackColor=System.Drawing.Color.Silver;
141this.butSend.FlatAppearance.BorderColor=System.Drawing.Color.Silver;
142this.butSend.FlatAppearance.BorderSize=0;
143this.butSend.FlatStyle=System.Windows.Forms.FlatStyle.Popup;
144this.butSend.Font=newSystem.Drawing.Font("楷体",21.75F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(134)));
145this.butSend.Location=newSystem.Drawing.Point(431,395);
146this.butSend.Name="butSend";
147this.butSend.Size=newSystem.Drawing.Size(145,64);
148this.butSend.TabIndex=6;
149this.butSend.Text="发送";
150this.butSend.UseVisualStyleBackColor=false;
151this.butSend.Click+=newSystem.EventHandler(this.butSend_Click);
152//
153//timer
154//
155this.timer.Interval=1000;
156this.timer.Tick+=newSystem.EventHandler(this.timer_Tick);
157//
158//labelIP
159//
160this.labelIP.AutoSize=true;
161this.labelIP.Location=newSystem.Drawing.Point(9,322);
162this.labelIP.Name="labelIP";
163this.labelIP.Size=newSystem.Drawing.Size(63,14);
164this.labelIP.TabIndex=7;
165this.labelIP.Text="对方主机";
166//
167//labelName
168//
169this.labelName.AutoSize=true;
170this.labelName.Location=newSystem.Drawing.Point(12,9);
171this.labelName.Name="labelName";
172this.labelName.Size=newSystem.Drawing.Size(35,14);
173this.labelName.TabIndex=8;
174this.labelName.Text="昵称";
175//
176//mainForm
177//
178this.AutoScaleDimensions=newSystem.Drawing.SizeF(7F,14F);
179this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
180this.BackColor=System.Drawing.Color.Silver;
181this.BackgroundImage=global:
:
OO.Properties.Resources.bg01;
182this.ClientSize=newSystem.Drawing.Size(588,471);
183this.Controls.Add(this.labelName);
184this.Controls.Add(this.labelIP);
185this.Controls.Add(this.butSend);
186this.Controls.Add(this.butClose);
187this.Controls.Add(this.butClear);
188this.Controls.Add(this.textName);
189this.Controls.Add(this.textIP);
190this.Controls.Add(this.rtbSend);
191this.Controls.Add(this.rtbContent);
192this.Font=newSystem.Drawing.Font("楷体",10.5F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(134)));
193this.FormBorderStyle=System.Windows.Forms.FormBorderStyle.FixedSingle;
194this.Icon=((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
195this.MaximizeBox=false;
196this.Name="mainForm";
197this.Text="OO";
198this.Load+=newSystem.EventHandler(this.mainForm_Load);
199this.ResumeLayout(false);
200this.PerformLayout();
201
202
203}
204
205
206#endregion
207
208
209privateSystem.Windows.Forms.RichTextBoxrtbContent;
210privateSystem.Windows.Forms.RichTextBoxrtbSend;
211privateSystem.Windows.Forms.TextBoxtextIP;
212privateSystem.Windows.Forms.TextBoxtextName;
213privateSystem.Windows.Forms.ButtonbutClear;
214privateSystem.Windows.Forms.ButtonbutClose;
215privateSystem.Windows.Forms.ButtonbutSend;
216privateSystem.Windows.Forms.Timertimer;
217privateSystem.Windows.Forms.LabellabelIP;
218privateSystem.Windows.Forms.LabellabelName;
219}
220}
221
222
223
224//文件Form1.cs
225usingSystem;
226usingSystem.Collections.Generic;