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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(C#网络聊天系统的方案设计书与实现.docx)为本站会员(b****1)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

C#网络聊天系统的方案设计书与实现.docx

1、C#网络聊天系统的方案设计书与实现封面作者:PanHongliang仅供个人学习摘 要21世纪人类进入了一个以网络计算机为中心的信息主导型时代,现在人们可以使用计算机在瞬间迅速地处理和传递大量信息。网络的快速发展使得信息交流的速度和方式发生了巨大的变化,人们已经越来越明显地看到了计算机网络带来的社会生活方面的巨大变革。随着互联网技术的飞速进步,有关网络的技术层出不穷,网络聊天系统也成为了一种深受大众喜爱、应用广泛的工具。网络聊天是互联网上一种非常普及的应用,文中以.NET平台作为开发工具,使用Socket作为应用程序开发模型,可方便服务器与客户端建立连接,数据传输和断开连接。此外,在开发的过程

2、中还采用了多线程技术,以完成客户进程间的调度,实现多用户操作。文章中设计了一个简单的桌面聊天系统,包括服务器端和客户端两个部分,服务器和客户端之间通过Socket编程技术实现建立连接的过程,并进行通信。服务器端主要包括如下功能:显示登陆服务器主机及端口号,记录登陆用户并管理用户基本信息。客户端分为用户登陆和聊天两个子模块,两个模块包括如下功能:显示服务器端口、用户登陆、管理用户聊天记录、显示用户状态和私聊模式。关键词:网络聊天系统,服务器端,客户端,Socket,多线程ABSTRACTThe 21st century, mankind has entered a information-ori

3、ented era of network computer as the center , now people can use the computer rapidly processing and transmisting informationin an instant. The rapid development of network makes the exchange of information rate and manner has taken place tremendous changes, it is more and more evident that enormous

4、 changes of the social life brought about by the computer networks.As the internet is developing rapidly, the technology on network emerges one another instantly.The network chat system is also becoming a popular, widely-used tool.Network chat on the internet is a very popular application, in the te

5、xt, we use .NET platform as a development tool, and socket as the application development model, to facilitate the establishment of the client and server connectivity, data transmission and disconnect. In addition, in the process of developing also usesthe multi-threaded technology to complete the p

6、rocessfor scheduling, and multi-user operation. The article designs a simple desktop chat system, including server and client in two parts, between the client and server through Socket programming technology to connect the process, and communications.The server end mainly includes the following func

7、tions: showing landing server host and port number, users log records andmanageuser basic information. The customer end module was divided into two pieces of module, logining and chating, which include the following functions: showing server port, logining, the management of user chats, showing user

8、s state and private model.Keywords:Network Chat System, the server end, the client end, Socket, multi-threading technology目 录第1章引言11.1 课题的背景及意义11.2 课题的研究现状11.3 本文的组织方式2第2章关键技术及开发工具42.1 TCP/IP协议和Socket简介42.1.1 TCP协议简介52.1.2 端口简介62.1.3 名称空间62.1.4 Socket编程技术72.2 多线程技术92.3 开发工具介绍10第3章网络聊天系统分析123.1 系统实现目

9、标及基本原理123.2 需求分析123.2.1 功能需求分析123.2.2 性能需求分析133.3 系统体系结构13第4章系统设计154.1 系统模块分析154.2 服务器端的设计174.3 客户端的设计18第5章系统实现205.1 服务器端的实现205.1.1 服务器初始化215.1.2 建立与客户端连接225.1.3 与客户端通信235.1.4 向客户端发送命令235.2 客户端的实现245.2.1 登陆子模块的实现245.2.2 客户端聊天子模块的实现26结论30参考文献31致谢331.3本文的组织方式本文对网络聊天系统进行了详细的分析研究,并采用当今比较主流的技术进行了设实现计。本文共

10、有5章。第1章 引言 主要是给出课题的研究背景、研究的现状,并且概括了论文主要内容。第2章 关键技术及开发工具 介绍了聊天系统所采用的关键技术,并对系统开发工具进行了简单的介绍。第3章 系统分析与设计 首先介绍系统实现的基本原理,给出了要实现的目标并对其进行需求分析,并重点给出了系统的体系结构。第4章 系统详细设计 首先对系统的功能模块进行划分,并着重给出了系统的详细设计方案。第5章 系统实现 针对系统功能模块分别进行实现,包括服务器部分和客户端部分。总结 对所做的研究和设计进行总结。最后附上致谢和参考文献!本聊天系统的总体框架如图4.1所示:图4.2服务器端程序流程图图5.4用户沈亚坤的初始

11、窗口5.2.2客户端聊天子模块的实现在ChatClient工程中将Form1.cs重命名为ChatClientForm.cs,为了使用Socket对象和Thread对象,在代码文件中加入名字空间System.Net、System.Net.Sockets和System.Thread的引用。当加载窗体时,便会进入ChatClientForm_Load处理程序,在ChatClientForm_Load处理程序中,首先显示用户登录窗口,如图5.3所示。如果登录成功,那么获取与服务器的连接并得到与服务器数据交互的流通道,向服务器发送CONN请求命令,同时启动一个新的线程用于响应从服务器发回的信息(在方法

12、ServerResponse()中实现)。ServerResponse()方法用于和服务器进行数据通信,主要是接收从服务器发回的信息,根据不同的命令,执行相应的操作。当选中“悄悄话”复选框时,便会进入priCheckBox_CheckedChanged处理程序。用户进行私聊时的程序流程图如图5.5所示:图5.5私聊流程图在priCheckBox_CheckedChanged处理程序中主要对privatemode布尔属性进行设置,具体代码如下:private void priCheckBox_CheckedChange(object sender,System.EventArgs e)If(pr

13、iCheckBox.Checked) Privatemode=true;ElsePrivatemode=false;当单击“发送”按钮时,便会进入btnSend_Click处理程序。在btnSend_Click处理程序中,如果privatemode布尔属性值为false(说明不是私聊),将CHAT命令发送给服务器;否则(为私聊),将PRIV命令发送给服务器,注意命令格式一定要与服务器端的命令格式一致,用户私聊模式如图5.6所示。图5.6卢胜宝收到沈亚坤的信息后的窗口当单击“离开”按钮时,便进入了btnExit_Click处理程序。在btnExit_Click处理程序中,将EXIT命令发送给服务

14、器,此命令格式要与服务器端的命令格式一致,具体代码如下:Private void btnExit_Click(Object sender , System.EventArgs e)String message=”EXIT|”+UserAlias+”|;/将字符串转化为字符数组Byteoutbytes=System.Text.Encoding.ASCII.GetBytes(message.ToCharArray();/利用NetworkStream的Write方法发送Strm.Write(outbytes,0,outbytes.Length);用户离开后其他在线用户的窗口显示如图5.7所示:图5

15、.7 用户崔小东离开后卢胜宝的窗口从图中可以看出,用户崔小东离开后,卢胜宝的在线用户列表中的他的名字已经被删除,并在信息栏里给出提示。Powered by 版权申明本文部分内容,包括文字、图片、以及设计等在网上搜集整理。版权为潘宏亮个人所有This article includes some parts, including text, pictures, and design. Copyright is Pan Hongliangs personal ownership.用户可将本文的内容或服务用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定

16、,不得侵犯本网站及相关权利人的合法权利。除此以外,将本文任何内容或服务用于其他用途时,须征得本人及相关权利人的书面许可,并支付报酬。Users may use the contents or services of this article for personal study, research or appreciation, and other non-commercial or non-profit purposes, but at the same time, they shall abide by the provisions of copyright law and other

17、relevant laws, and shall not infringe upon the legitimate rights of this website and its relevant obligees. In addition, when any content or service of this article is used for other purposes, written permission and remuneration shall be obtained from the person concerned and the relevant obligee.转载

18、或引用本文内容必须是以新闻性或资料性公共免费信息为使用目的的合理、善意引用,不得对本文内容原意进行曲解、修改,并自负版权等法律责任。Reproduction or quotation of the content of this article must be reasonable and good-faith citation for the use of news or informative public free information. It shall not misinterpret or modify the original intention of the content of this article, and shall bear legal liability such as copyright.

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2