首页 网络技术 网络基础     /    基于TCP的网络聊天室的设计(一步一步教你CSocket网络编程)

基于TCP的网络聊天室的设计(一步一步教你CSocket网络编程)

上传者: pfkfengyun | 上传时间:2023/7/8 2:52:45 | 文件大小:4.88MB | 文件类型:rar
基于TCP的网络聊天室的设计(一步一步教你CSocket网络编程)
里面包含聊天室的客户端和服务器端的源文件和一份完整的设计报告。
一、 系统概要本系统能实现基于VC++的网络聊天室系统。
有单独的客户端、服务器端。
服务器应用程序能够接受来自客户端的广播,然后向客户端发送本机的IP与服务端口,让客户端接入到服务器进行聊天,检测用户名是否合法(重复),服务器责接收来自客户端的聊天信息,并根据用户的需求发送给指定的人或所有人,能够给出上线下线提示。
客户端能够发出连接请求,能编辑发送信息,可以指定发给单人或所有人,能显示聊天人数,上线下线用户等。
二、 通信规范的制定服务请求规范:服务器端:(1)创建一个UDP的套接字,接受来自客户端的广播请求,当请求报文内容为“REQUESTFORIPADDRESSANDSERVERPORT”时,接受请求,给客户端发送本服务器TCP聊天室的端口号。
(2)创建一个主要的TCP协议的套接字负责客户端TCP连接,处理它的连接请求事件。
(3)在主要的TCP连接协议的套接字里面再创建TCP套接字保存到动态数组里,在主要的套接字接受请求后,就用这些套接字和客户端发送和接受数据。
客户端:(1)当用户按“连接”按钮时,创建UDP协议套接字,给本地计算机发广播,广播内容为“REQUESTFORIPADDRESSANDSERVERPORT”。
(2)当收到服务器端的回应,收到服务器发来的端口号后,关闭UDP连接。
根据服务器的IP地址和端口号重新创建TCP连接。
故我思考:客户端一定要知道服务器的一个端口,我假设它知道服务器UDP服务的端口,通过发广播给服务器的UDP服务套接字,然后等待该套接字发回服务器TCP聊天室服务的端口号,IP地址用ReceiveForom也苛刻得到。
通信规范通信规范的制定主要跟老师给出的差不多,并做了一小点增加:(增加验证用户名是否与聊天室已有用户重复,在服务器给客户端的消息中,增加标志0)①TCP/IP数据通信---“聊天”消息传输格式客户机-服务器(1)传输“用户名”STX+1+用户名+ETX(2)悄悄话STX+2+用户名+”,”+内容+ETX(3)对所有人说STX+3+内容+ETX服务器-客户机 (0)请求用户名与在线用户名重复 //改进 STX+0+用户名+EXT(1)首次传输在线用户名STX+1+用户名+ETX(2)传输新到用户名STX+2+用户名+ETX(3)传输离线用户名STX+3+用户名+ETX(4)传输聊天数据STX+4+内容+ETX(注:STX为CHR(2),ETX为CHR(3))三、 主要模块的设计分析四、 系统运行效果(要求有屏幕截图)五、 心得与体会

文件下载

资源详情

[{"title":"(78个子文件4.88MB)基于TCP的网络聊天室的设计(一步一步教你CSocket网络编程)","children":[{"title":"ChatServer","children":[{"title":"ServerSocket.h <span style='color:#111;'>1.89KB</span>","children":null,"spread":false},{"title":"ChatServer.opt <span style='color:#111;'>60.50KB</span>","children":null,"spread":false},{"title":"StdAfx.cpp <span style='color:#111;'>212B</span>","children":null,"spread":false},{"title":"resource.h <span style='color:#111;'>1.03KB</span>","children":null,"spread":false},{"title":"UDPSocket.cpp <span style='color:#111;'>1.38KB</span>","children":null,"spread":false},{"title":"ChatServerDlg.h <span style='color:#111;'>1.72KB</span>","children":null,"spread":false},{"title":"PortInput.cpp <span style='color:#111;'>1000B</span>","children":null,"spread":false},{"title":"UDPSocket.h <span style='color:#111;'>1.30KB</span>","children":null,"spread":false},{"title":"ChatServer.dsw <span style='color:#111;'>733B</span>","children":null,"spread":false},{"title":"ClientSocket.cpp <span style='color:#111;'>4.45KB</span>","children":null,"spread":false},{"title":"ChatServer.dsp <span style='color:#111;'>4.78KB</span>","children":null,"spread":false},{"title":"ServerSocket.cpp <span style='color:#111;'>4.28KB</span>","children":null,"spread":false},{"title":"ChatServer.cpp <span style='color:#111;'>2.00KB</span>","children":null,"spread":false},{"title":"ClientSocket.h <span style='color:#111;'>1.83KB</span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"ChatServer.pdb <span style='color:#111;'>465.00KB</span>","children":null,"spread":false},{"title":"vc60.pdb <span style='color:#111;'>388.00KB</span>","children":null,"spread":false},{"title":"UDPSocket.obj <span style='color:#111;'>9.09KB</span>","children":null,"spread":false},{"title":"vc60.idb <span style='color:#111;'>225.00KB</span>","children":null,"spread":false},{"title":"ClientSocket.obj <span style='color:#111;'>25.27KB</span>","children":null,"spread":false},{"title":"ChatServer.pch <span style='color:#111;'>5.31MB</span>","children":null,"spread":false},{"title":"ChatServer.ilk <span style='color:#111;'>346.02KB</span>","children":null,"spread":false},{"title":"ChatServerDlg.obj <span style='color:#111;'>22.66KB</span>","children":null,"spread":false},{"title":"PortInput.obj <span style='color:#111;'>9.93KB</span>","children":null,"spread":false},{"title":"ServerSocket.obj <span style='color:#111;'>46.26KB</span>","children":null,"spread":false},{"title":"StdAfx.obj <span style='color:#111;'>103.88KB</span>","children":null,"spread":false},{"title":"ChatServer.obj <span style='color:#111;'>14.02KB</span>","children":null,"spread":false},{"title":"ChatServer.res <span style='color:#111;'>98.77KB</span>","children":null,"spread":false}],"spread":false},{"title":"ReadMe.txt <span style='color:#111;'>3.57KB</span>","children":null,"spread":false},{"title":"StdAfx.h <span style='color:#111;'>1.02KB</span>","children":null,"spread":false},{"title":"PortInput.h <span style='color:#111;'>1.19KB</span>","children":null,"spread":false},{"title":"ChatServer.rc <span style='color:#111;'>5.96KB</span>","children":null,"spread":false},{"title":"ChatServer.clw <span style='color:#111;'>1.80KB</span>","children":null,"spread":false},{"title":"ChatServer.h <span style='color:#111;'>1.20KB</span>","children":null,"spread":false},{"title":"ChatServer.plg <span style='color:#111;'>254B</span>","children":null,"spread":false},{"title":"res","children":[{"title":"ChatServer.rc2 <span style='color:#111;'>402B</span>","children":null,"spread":false},{"title":"ChatServer.ico <span style='color:#111;'>96.34KB</span>","children":null,"spread":false},{"title":"Master.manifest <span style='color:#111;'>693B</span>","children":null,"spread":false},{"title":"icon1.ico <span style='color:#111;'>96.34KB</span>","children":null,"spread":false}],"spread":false},{"title":"ChatServer.aps <span style='color:#111;'>117.40KB</span>","children":null,"spread":false},{"title":"ChatServerDlg.cpp <span style='color:#111;'>3.52KB</span>","children":null,"spread":false},{"title":"icon1.ico <span style='color:#111;'>96.34KB</span>","children":null,"spread":false},{"title":"ChatServer.ncb <span style='color:#111;'>129.00KB</span>","children":null,"spread":false}],"spread":false},{"title":"ChatClient","children":[{"title":"ChatClient.cpp <span style='color:#111;'>2.13KB</span>","children":null,"spread":false},{"title":"StdAfx.cpp <span style='color:#111;'>212B</span>","children":null,"spread":false},{"title":"ChatClient.ncb <span style='color:#111;'>121.00KB</span>","children":null,"spread":false},{"title":"UserNameDlg.h <span style='color:#111;'>1.25KB</span>","children":null,"spread":false},{"title":"ChatClient.opt <span style='color:#111;'>55.50KB</span>","children":null,"spread":false},{"title":"resource.h <span style='color:#111;'>1.03KB</span>","children":null,"spread":false},{"title":"ChatClient.h <span style='color:#111;'>1.34KB</span>","children":null,"spread":false},{"title":"ChatClient.dsw <span style='color:#111;'>733B</span>","children":null,"spread":false},{"title":"ChatClient.rc <span style='color:#111;'>5.90KB</span>","children":null,"spread":false},{"title":"ClientSocket.cpp <span style='color:#111;'>6.77KB</span>","children":null,"spread":false},{"title":"ChatClientDlg.h <span style='color:#111;'>1.73KB</span>","children":null,"spread":false},{"title":"ChatClient.aps <span style='color:#111;'>117.36KB</span>","children":null,"spread":false},{"title":"ClientSocket.h <span style='color:#111;'>2.25KB</span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"vc60.pdb <span style='color:#111;'>364.00KB</span>","children":null,"spread":false},{"title":"vc60.idb <span style='color:#111;'>217.00KB</span>","children":null,"spread":false},{"title":"ClientSocket.obj <span style='color:#111;'>38.68KB</span>","children":null,"spread":false},{"title":"ChatClient.res <span style='color:#111;'>98.88KB</span>","children":null,"spread":false},{"title":"ChatClient.pdb <span style='color:#111;'>425.00KB</span>","children":null,"spread":false},{"title":"ChatClientDlg.obj <span style='color:#111;'>22.22KB</span>","children":null,"spread":false},{"title":"UserNameDlg.obj <span style='color:#111;'>12.10KB</span>","children":null,"spread":false},{"title":"StdAfx.obj <span style='color:#111;'>103.88KB</span>","children":null,"spread":false},{"title":"ChatClient.ilk <span style='color:#111;'>315.86KB</span>","children":null,"spread":false},{"title":"ChatClient.obj <span style='color:#111;'>13.58KB</span>","children":null,"spread":false},{"title":"ChatClient.pch <span style='color:#111;'>5.31MB</span>","children":null,"spread":false}],"spread":false},{"title":"ReadMe.txt <span style='color:#111;'>3.57KB</span>","children":null,"spread":false},{"title":"StdAfx.h <span style='color:#111;'>1.02KB</span>","children":null,"spread":false},{"title":"ChatClientDlg.cpp <span style='color:#111;'>4.56KB</span>","children":null,"spread":false},{"title":"ChatClient.dsp <span style='color:#111;'>4.46KB</span>","children":null,"spread":false},{"title":"res","children":[{"title":"ChatClient.rc2 <span style='color:#111;'>402B</span>","children":null,"spread":false},{"title":"Master.manifest <span style='color:#111;'>693B</span>","children":null,"spread":false},{"title":"ChatClient.ico <span style='color:#111;'>96.34KB</span>","children":null,"spread":false}],"spread":false},{"title":"ChatClient.clw <span style='color:#111;'>1.75KB</span>","children":null,"spread":false},{"title":"UserNameDlg.cpp <span style='color:#111;'>1.02KB</span>","children":null,"spread":false},{"title":"ChatClient.plg <span style='color:#111;'>254B</span>","children":null,"spread":false}],"spread":false},{"title":"实验指导书.doc <span style='color:#111;'>2.04MB</span>","children":null,"spread":false},{"title":"设计报告.doc <span style='color:#111;'>255.00KB</span>","children":null,"spread":false}],"spread":true}]

评论信息

  • zhaonengzhi:
    非常有价值2019-05-16
  • lorde_mimi:
    不错,有参考价值2019-05-07
  • milk_sw:
    感觉还可以2018-07-04
  • er天:
    非常好的资源2018-01-26
  • zzx609378338:
    呜呜呜,我们老师上来就要我们编写这个聊天室,天哪,我们连c++都才刚学一个月多啊!果然,这篇文档还是看的一脸懵。。。2017-11-19

免责申明

【好快吧下载】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【好快吧下载】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【好快吧下载】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,8686821#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明