文件名称:Java-liaotian
下载
别用迅雷、360浏览器下载。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
介绍说明--下载内容均来自于网络,请自行研究使用
一个Java聊天程序服务端和客户端程序,C/S结构,ChatServer 类实现了一个聊天室服务器端, 此类有一个构造器, 在构造器中使用newServerSocket()建立一个Socket 连接。RunServer()方法中运行聊天服务,通过Socket 类的getInetAddress().getHostName() 方法获得主机名, 建立新的ChatHandler 对象实例, 在synchronized (clients)中取得与客户端的同步。内部类ChatHandler 继承了Thread 类,在此线程run()方法中处理一次交谈。Close()方法关闭与客户端的连接。
ChatRoom 类继承了Applet,在init()中通过new fr a me()创建聊天窗体,并在此窗体中设置窗体布局。在login()方法中,通过new Socket(serverHost, port)建立与服务器的连接,通过new Thread()产生新的聊天线程。在logout()方法中,使用sock.close()关闭连接。-A Java chat server and client service procedures, C/S structure, ChatServer class implements a chat room on the server side, such a constructor, use newServerSocket in the constructor () to create a Socket connection. RunServer () method to run the chat service, (). GetHostName () method to get the host name through the Socket class getInetAddress, create a new ChatHandler object instance, to synchronize with the client synchronized (clients) in. Internal class ChatHandler inherited Thread class, in this thread run () method of processing a conversation. Close () method closes the connection with the client. ChatRoom class inherits Applet, () to create a chat window by new fr a me init () in, and set the form layout in this form. In the login () method to establish a connection with the server via new Socket (serverHost, port), to generate new chat thread through new Thread (). In the logout () method, using sock.close () closes the connection.
ChatRoom 类继承了Applet,在init()中通过new fr a me()创建聊天窗体,并在此窗体中设置窗体布局。在login()方法中,通过new Socket(serverHost, port)建立与服务器的连接,通过new Thread()产生新的聊天线程。在logout()方法中,使用sock.close()关闭连接。-A Java chat server and client service procedures, C/S structure, ChatServer class implements a chat room on the server side, such a constructor, use newServerSocket in the constructor () to create a Socket connection. RunServer () method to run the chat service, (). GetHostName () method to get the host name through the Socket class getInetAddress, create a new ChatHandler object instance, to synchronize with the client synchronized (clients) in. Internal class ChatHandler inherited Thread class, in this thread run () method of processing a conversation. Close () method closes the connection with the client. ChatRoom class inherits Applet, () to create a chat window by new fr a me init () in, and set the form layout in this form. In the login () method to establish a connection with the server via new Socket (serverHost, port), to generate new chat thread through new Thread (). In the logout () method, using sock.close () closes the connection.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Java聊天程序服务端和客户端程序