文件名称:clientANDserver

  • 所属分类:
  • JSP源码/Java
  • 资源属性:
  • [Java] [源码]
  • 上传时间:
  • 2012-11-26
  • 文件大小:
  • 10kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • lany****
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

聊天室的实现要实现客户端(cilent)和服务端(server),客户端(client)和服务端(server)通过Socket建立必要的连接。并让服务端(server)程序监听一个众所周知的端口。当客户端(client)的连接请求到达时,如果服务端(server)同意建立连接,则将创建一个新的Soket并绑定到另一个端口,使用这个新建的Socket与该客户端(client)建立连接,而服务端(server)继续在与原来的端口监听,等待新的连接请求。

当连接建立后,通过输入/输出流并通过这些流进行数据的传输。

当两个主机之间的通信结束时,则要关闭连接。关闭连接通过关闭Socket可以调用Socket类的close()方法。其中应该先将与Socket相关的所有输入/输出流关闭,最后在关闭Socket。

建立一个ChatClient类:该类中的createUI()方法实现的聊天界面 ,connect()方法实现端口的连接等;



2.建立一个ChatServer类:该类中服务端(server)应用程序采用多线程机制,可以支持客户端(client)的并发访问。-The realization of the chat room to achieve the client (cilent) and end (server) and client (client) and server (server) Socket establish the necessary connection.And let the server (server) listens on a well-known port. When the client (client) connection request arrives, the server (server) agreed to establish a connection, it will create a new Soket and bind to another port, the use of this new Socket and the client (client) to establish connected to the server (server) to continue with the original port listener, waiting for a new connection request.

 When the connection is established, through the input/output streams and these streams of data transmission.

 When the end of the communication between the two hosts, will have to close the connection. Close the connection by closing the Socket can call the close () method of the Socket class. Which should be first of all related with Socket input/output streams closed, and finally closed the Socket.

Establish a ChatClient class:
(系统自动生成,下载前可以参看下载内容)

下载文件列表





clientANDserver\.classpath

...............\.project

...............\.settings\org.eclipse.jdt.core.prefs

...............\bin\ChatClient$1.class

...............\...\ChatClient.class

...............\...\ChatServer.class

...............\...\MyClientListener.class

...............\...\MyClientReader.class

...............\...\MyServerReader.class

...............\src\ChatClient.java

...............\...\ChatServer.java

...............\.settings

...............\bin

...............\src

clientANDserver

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org