JISHOUUNIVERSITY专业课课程论文题目:利用java套接字实现双机通信作者:学号:所属学院:信息科学与工程学院专业年级:总评分:完成时间:吉首大学信息科学与工程学院利用Java套接字实现双机通信(吉首大学信息科学与工程学院,湖南吉首416000)摘要Socket(套接字)是一种基于TCP/IP的编程接口。它采用客户/服务器通信机制,使客户端和服务器端通过Socket接口在网络上实现连接和数据交换。它提供了一系列系统调用,使用户可以方便地实现TCP和UDP等多种网络协议的通信。它使用户可以在网络协议上工作而不必对该网络协议有非常深入的了解。这样编写的程序可被迅速移植到任何支持Socket的网络系统中去。在Internet上的主机一般运行了多个服务软件,同时提供几种服务。每种服务都打开一个Socket,并绑定到一个端口上,不同的端口对应于不同的服务。Socket正如其英文原意那样,象一个多孔插座。一台主机犹如布满各种插座的房间,每个插座有一个编号,有的插座提供220伏交流电,有的提供110伏交流电,有的则提供有线电视节目。客户软件将插头插到不同编号的插座,就可以得到不同的服务。本文通过主要利用JavaSocket来实现双机通信,实现一个简单的服务器,客户端聊天通信工具。并对JavaSocket的实现进行简单的分析和讲解,通过本文以达到对Socket的原理又一个较清晰的认识。关键词:套接字、SocketServer类、客户机/服务器模式UsingJavasocketrealizedtwo-machinecommunicationChenwenzhao(CollegeofInformationScienceandEngineering,JishouUniversity,Jishou,Hunan416000)AbstractSocketisaprogramminginterfacebasedonTCP/IP.Itusesaclient/servercommunicationmechanism,sothattheclientandserverthroughtheSocketinterfaceimplementedonanetworkconnectionanddataexchange.Itprovidesasetofsystemcall,theusercanconvenientlyrealizetheTCPandUDPwaitforavarietyofnetworkprotocolcommunication.Itletstheuserinthenetworkprotocoltoworkwithoutthenetworkprotocolhasaveryin-depthunderstanding.ThisprogramcanbequicklyportedtosupportanyoftheSocketnetworksystemin.IntheInternetonthehostgenerallyrunningmultipleservicesoftware,atthesametimeprovideseveralservices.EachoftheserviceswillopenaSocket,andbindtoaport,adifferentportcorrespondingtodifferentservices.SocketasitsEnglishmeaningthat,likeaporoussocket.Ahostcomputerisfullofallkindsofsocketroom,eachreceptaclehasanumber,andsomesocket220voltAC,providesome110voltAC,whileothersprovidecabletelevisionprogram.Theclientsoftwarewillplugintothesocketofdifferentnumber,cangetthedifferentservices.ThispapermainlyusesJavaSockettoachievedouble-machinecommunications,toachieveasimplechatserver,theclientcommunicationtools.AndJavaSockettoachieveasimpleanalysisandexplanation,throughthispapertoachievetheprincipleofSocketandamoreclearunderstandingof.Keywords:socket,SocketServer,client/ServerMode目录第一章引言........................................................................................................................51.1课题背景及意义........................................................................................................51.2课题研究现状............................................................................................................51.3研究内容....................................................................................................................6第二章理论基础................................................................................................................62.1套接字通信................................................................................................................62.2JAVASockets编程概述:........................................