文件名称:Java-liaotian
介绍说明--下载内容来自于网络,使用问题请自行百度
一个Java聊天程序服务端和客户端程序,C/S结构,ChatServer 类实现了一个聊天室服务器端, 此类有一个构造器, 在构造器中使用newServerSocket()建立一个Socket 连接。RunServer()方法中运行聊天服务,通过Socket 类的getInetAddress().getHostName() 方法获得主机名, 建立新的ChatHandler 对象实例, 在synchronized (clients)中取得与客户端的同步。内部类ChatHandler 继承了Thread 类,在此线程run()方法中处理一次交谈。Close()方法关闭与客户端的连接。
ChatRoom 类继承了Applet,在init()中通过new Frame()创建聊天窗体,并在此窗体中设置窗体布局。在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 Frame 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 Frame()创建聊天窗体,并在此窗体中设置窗体布局。在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 Frame 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聊天程序服务端和客户端程序/codefans.net/聊天/CHAT.HTML
Java聊天程序服务端和客户端程序/codefans.net/聊天/CHAT.JAVA
Java聊天程序服务端和客户端程序/codefans.net/聊天/CHATROOM.JAVA
Java聊天程序服务端和客户端程序/codefans.net/聊天/CHATSERVER.JAVA
Java聊天程序服务端和客户端程序/codefans.net/聊天
Java聊天程序服务端和客户端程序/codefans.net
Java聊天程序服务端和客户端程序
Java聊天程序服务端和客户端程序/codefans.net/聊天/CHAT.JAVA
Java聊天程序服务端和客户端程序/codefans.net/聊天/CHATROOM.JAVA
Java聊天程序服务端和客户端程序/codefans.net/聊天/CHATSERVER.JAVA
Java聊天程序服务端和客户端程序/codefans.net/聊天
Java聊天程序服务端和客户端程序/codefans.net
Java聊天程序服务端和客户端程序
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.