Introduction - If you have any usage issues, please Google them yourself
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.