欢迎来到天天文库
浏览记录
ID:48000904
大小:282.59 KB
页数:11页
时间:2020-01-11
《基于TCP协议通信系统的设计与实现.pdf》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、基于TCP协议通信系统的设计与实现摘要:通信协议(communicationsprotocol)是指双方实体完成通信或服务所必须遵循的规则和约定。协议定义了数据单元使用的格式,信息单元应该包含的信息与含义,连接方式,信息发送和接收的时序,从而确保网络中数据顺利地传送到确定的地方。通信的底层通信是通过SOCKET套接字接口实现的。当前的主流UNIX系统和微软的WINDOWS系统都在内核提供了对SOCKET字接口的支持。使用这个统一的接口,可以编写一个可移植的TCP通信程序。本文设计并实现了基于局域网内的简单即时通信系统,系统采用C/S模式,底层通信通过SOCKET
2、套接字接口实现,服务器负责客户端的登录验证,好友信息的保存和心跳报文的发送。客户端采用P2P方式实现消息传递,并能实现文件的传输。本文首先讨论了同步套接字,异步套接字,多线程并发执行任务等;然后阐述了客户端、服务器如何使用XML序列化的消息进行通信。关键词:TCP协议;通信协议系统;套接字;文件传输;C/S模式;TheSystemDesignandImplementationofBasedonTCPProtocolCommunicationAbstract:Communicationprotocol(communicationsprotocol)refersto
3、bothentitiestocompletecommunicationorservicemustfollowtherulesandconventions.Theprotocoldefinesadataunitformat,informationunitshouldcontaininformationandmeaning,connectionmode,informationtransmissionandreceptiontiming,therebyensuringthatthenetworkdatasmoothlytransmittedtodeterminepla
4、ces.CommunicationcommunicationisthroughtheSOCKETsocketinterfaceimplementation.ThecurrentmainstreamUNIXsystemandMicrosoftWINDOWSsysteminthekernelprovidestoSOCKETinterfacesupport.Usingtheunifiedinterface,canbepreparedinatransplantableTCPcommunicationprogram.Thispaperdesignedandimplemen
5、tedbasedonasimpleLANinstantcommunicationsystem,thesystemadoptsC/Smodel,theunderlyingcommunicationthroughtheSOCKETsocketinterfaceimplementation,serverfortheclienttologinauthentication,friendsofinformationpreservationandheartbeatmessagesending.ClientusingP2Pmodetorealizetheinformationt
6、ransmission,andcanrealizethefiletransfer.Thispaperfirstdiscussesthesynchronizationsocket,asynchronoussocket,multithreadingconcurrentexecutionofthetask;andthendescribestheclient,theservercanusetheXMLserializationofnewscommunication.Keywords:TCPprotocol;communicationprotocolsystem;sock
7、et;filetransfer;C/Smodel;第1页1引言1.1研究背景在计算机通信中,通信协议用于实现计算机与网络连接之间的标准,网络如果没有统一的通信协议,电脑之间的信息传递就无法识别。通信协议是指通信各方事前约定的通信规则,可以简单地理解为各计算机之间进行相互会话所使用的共同语言。两台计算机在进行通信时,必须使用的通信协议。TCP/IP(TransportControlProtocol/InternetProtocol,传输控制协议/Internet协议)的历史应当追溯到Internet的前身—ARPAnet时代。为了实现不同网络之间的互连,美国国防部
8、于1977年到1979年
此文档下载收益归作者所有