JAVA聊天室系统的设计与实现摘要随着时代的发展,时间、信息两个概念显得越来越突出。在第一时间掌握第一手资料,是打败对手取得成功的秘诀。伴随着计算机网络技术的迅速发展,通信业也蒸蒸日上。现在个人电脑已普及到各个家庭、单位中。为了能实时、准确地实现与朋友、亲人、同事之间的联系,网络聊天是一种比较经济实惠的途径,其发展前景可观。本系统利用Java中的socket网络编程和多线程技术实现。主要包括登陆连接、服务器管理、客户聊天三大功能。管理员和用户经过登陆界面分别进入到服务器端和客户端,客户通过socket连接服务器,服务器通过多线程技术转发信息到其他客户端。这种服务器集中转发信息的优点是通信稳定,缺点是增加了服务器端的负担。传统的面对面之间的交流由于受地域和时间的影响,已经满足不了当今社会的需求。利用聊天室这种影响将会降到最小,人与人之间的交流将会更加方便、快捷,可以大幅度提高人们的交流效率。关键词:聊天室;Java;socket;多线程;C/SJAVA聊天室系统的设计与实现AbstractWiththedevelopmentandprogressofthetimes,theconceptoftimeandinformationbecomemoreandmoreoutstanding.So,thewinnerswillbetheoneswhofirstgraspthefirsthanddata.Astheinternettechnologyisdevelopingrapidly,thecommunicationsindustryisalsothriving.Personalcomputersareextensivelyspreadingamongallfamiliesandunits.Inordertocommunicatewithfamilymembers,friendsandworkmatesaccuratelybutonrealtime,chattingonnetisoneofthemoreeconomicalandsubstantialways,whichhasafavorableprospect.ThissystemtakeseffectbysocketnetworkprogramofJavaandmulti-thread,Ithasthreemainfunctionsoflogin,serversmanageandchatting.Theadministratoranduserlogonserver-sideandclient-sideseparatelybytheloginbox.Theclientsconnectthemselvestoserversthroughthesocket,thentheserverssendthesemessagestootherclientsbymulti-thread.Theadvantageofforwardinginformationscentrallyresultsinastablecommunication,butitsweaknessleadstoaburdentotheserver-side.Traditionalface-to-facecommunicationisrestrictedbytimeandregion,whichcannotmeetthedemandsofmodernsociety.Chattingroomcanreducetheinfluenceabovetotheminimum,andthecommunicationamongpeoplewillbemoreconvenientandquick,theintercourseefficiencyisincreasedgreatly.Keywords:chattingroom;java;socket;multi-thread;c/sJAVA聊天室系统的设计与实现目录第1章绪论.......................................................................................................11.1论文背景及课题来源..................................................................................11.2本课题在国内外的发展状况......................................................................11.3应解决的问题及系统开发意义..................................................................1第2章开发工具及相关技术介绍.....................................................................32.1JAVA与SOCKET简介...................................................................................32.2JBUILDER5介绍...........................................................................................32.3C/S模型介绍...............................................................................................42.4用JAVA实现SOCKET模型.........................................................................52.5JAVA中的线程模型简介..............................................................................62.6SQLSERVER2000简介.............................................................................6第3章系统需求分析.........................................................................................83.1系统任务描述.............................................................................................83.2系统功能分析.............................................................................................83.2.1系统的功能需求...................................................................................83.2.2系统数据流图........................................................................................93.2.3系统数据分析......................................................................................103.3系统可行性分析.......................................................................................11第4章系统设计...............................................................................................134.1系统总体结构设计...................................................................................134.2数据库设计...............................................................................................144.3系统功能模块详细设计...........................................................................15第5章编码与实现...........................................................................................185.1系统主要模块代码...................................................................................185.1.1启动、停止服务器..............................................................................185.1.2客户端连接服务器..............................................................................195.1.3聊天室发送信息.................................................................................20JAVA聊天室系统的设计与实现5.1.4服务器转发信息.................................................................................205.1.5服务器显示在线用户人数.................................................................215.2系统测试...................................................................................................21第6章结论.....................................................................................................25参考文献.............................................................................................................26致谢.............................................................................................................27附录.................................................................