本科毕业设计(论文)
1
(2009 届)
本科生毕业设计(论文)
基于 Java 的网络通信系统设计与实现
学 院、系:
计算机与通信学院
专 业:
通信工程
学 生 姓 名:
班 级:
学号
指导教师姓名:
职称
最终评定成绩
2009 年 6 月
本科生毕业设计(论文)
I
摘 要
在网络越来越发达的今天,人们对网络的依赖越来越多,越来越离不开网络,由
此而产生的聊天工具越来越多,例如,国外的 ICQ、国内腾讯公司开发的 OICQ。随着
网络聊天一类的聊天系统的发展日新月异,因此产生了制作一个类似 QQ 的网络聊天工
具。Java 是一种程序设计语言,它具有简单的、完全面向对象以及与平台无关的结构,
也具有可移植性、高性能和安全性,并提供了多线程的功能,而 Java 语言最大的成功
之处在于它的平台无关性和具有强大的网络编程功能,基于 Java 网络编程的强大功能,
本人将用 Java 编写一个网络聊天系统。
论文首先论述了系统的开发背景,并对所用到的开发工具与关键技术做了简单的
介绍。接着对系统的研究意义,研究现状及设计目标进行分析,通过对系统需求和可
行性进行分析,确定了系统的功能模块,并画出相应的功能结构图、模块图和数据流
图。其次按系统总体设计的结果,对系统中的数据库进行结构设计。
一般来说,聊天工具大多数由客户端程序和服务器程序,外加服务器端用于存放客
户数据的数据库组成,本系统采用客户机/服务器架构模式,通过 Java 提供的 Socket
类来连接客户机和服务器并使客户机和服务器之间相互通信,由于聊天是多点对多点
的,而 Java 提供的多线程功能,用多线程可完成多点对多点的聊天。数据库管理系统
用 SQL Server2000,完成并通过 JDBC-ODBC 桥访问数据库。聊天系统完成后将可进行
多人对多人的聊天,对好友进行添加、删除,对新用户的注册,发送消息、接受消息,
传输文件等功能。界面设计细分化,方便使用者操作和理解。服务器实现了查询和修
改等功能,程序逻辑联系较紧密。
关键词:JAVA,C/S,SQL Server 2000, 多线程, 数据库管理系统
本科毕业设计(论文)
II
ABSTRACT
More and more developed in the network today, people rely on more and more
networks, and can not leave with out it. This caused the chat materials become more
numerous, as the overseas ICQ system, the OICQ system that invented by Tencent Co., and
so on. So we create a network chat medium just like the QQ.Java is a programming
language with the simple construction which is completely object-oriented 。 Java also
possess the portability, high performance and security, and provide the multi – thread
function. The best success is its and its strong network programming function, base on this,
I will use Java to write a network chat system.
Firstly, the paper discussed the development background of the system, and made a
briefly introduction to the development tool and key technologies. Then analyzed the
system’s research significance , research present situation and project objective .According
to the requirement analysis and feasibility analysis ,it can confirm the system’s functional
module and draw corresponding functional configuration chart ,module chart and data
stream chart. On the basis of the result of system designing, the paper design database by
structured design method.
Generally speaking, most chat medium consist the client program, server program and
the server which is use to content the database. This system adopt client/server pattern and
the Socket class provide by Java to communicate the client and server. Because of chat is
many to many, the multithreading function can implement the many-many chat, database
management system use SQL Server2000 and JDBC-ODBC bridge to visit the database.
When chat system is achieved, it can possess functions like chat in a many-many way, add
and delete the intimate, the new user’s registration, and sending and receiving message,
transferring files and so on. The refinement of interface designing would facilitate user
operation and understanding. The contact surface has the thin differentiation designs;
modules have realized the functions such as inquiry, revision and so on. The logic
relationship in this program is closed.
Keyword: Java, Multithreading, Client/Server, SQL Server2000,
Database Management System
本科毕业设计(论文)
III
目 录
第 1 章 绪论.......................................................................................................1
1.1 课题选择的背景 ........................................................................................................1
1.2 课题选择意义 ............................................................................................................1
1.3 系统开发技术简介 ....................................................................................................2
1.3.1 Java 简介 ........................................................................................................2
1.3.2 JDBC 技术简介 ..................................................................................................2
1.3.3 数据库 Microsoft SQL-Server 2000 简介 ..................................................4
1.3.4 多线程介绍 .......................................................................................................4
第 2 章 系统分析...............................................................................................6
2.1 系统需求 ....................................................................................................................6
2.1.1 系统的特点分析 ...............................................................................................6
2.1.2 网络聊天系统需要解决的问题 .......................................................................6
2.2 系统设计思想 ............................................................................................................6
2.3 系统实现功能分析 ....................................................................................................7
2.4 系统开发及运行环境 ................................................................................................7
第 3 章 系统总体设计.......................................................................................8
3.1 总体构架 ....................................................................................................................8
3.2 系统整体功能 ............................................................................................................8
3.3 系统模块功能设计 ....................................................................................................9
第 4 章 数据库设计.........................................................................................12
4.1 系统 E-R 图 ..............................................................................................................12
4.2 数据字典 ..................................................................................................................12
4.3 各个数据表的创建 ..................................................................................................12
4.4 数据库的连接 ..........................................................................................................13
第 5 章 系统实现与编码.................................................................................15
5.1 服务器功能模块的设计 ..........................................................................................15
5.1.1 Socket 和 ServerSocket 介绍 ......................................................................15
本科毕业设计(论文)
IV
5.2 服务器功能模块的实现 ..........................................................................................16
5.2.1 多线程服务器模块实现 .................................................................................16
5.2.2 在线用户管理模块实现 .................................................................................18
5.2.3 部门管理模块实现 .........................................................................................20
5.2.4 用户管理模块实现 .........................................................................................21
5.2.5 日志管理模块实现 ..........................................................................................22
5.3 协议设计与实现 .......................................................................................................23
5.3.1 协议规则 .........................................................................................................23
5.3.2 协议实现 .........................................................................................................24
5.4 客户端功能模块的设计与实现 ...............................................................................27
5.4.1 登陆认证模块 .................................................................................................27
5.4.2 主界面模块 .....................................................................................................27
5.4.3 聊天模块 .........................................................................................................28
5.4.4 文件传输模块 .................................................................................................29
第 6 章 系统测试.............................................................................................33
6.1 系统测试概述 ..........................................................................................................33
6.1.1 测试目标 .........................................................................................................33
6.1.2 测试实例研究与选择 .....................................................................................33
6.1.3 系统测试环境 .................................................................................................33
6.2 测试内容 ..................................................................................................................34
6.2.1 服务器模块测试 .............................................................................................34
6.2.2 客户端模块测试 .............................................................................................34
6.2.3 平台兼容性测试 .............................................................................................35
6.3 测试结果分析评价 ..................................................................................................35
结 论...............................................................................................................36
参考文献...........................................................................................................37
致 谢.................................................................................................................38