Simple chat applet of Java network communication technology
This example shares the specific code of simple chat applet in Java for your reference. The specific contents are as follows
After learning Java Communication Technology, I made a simple form chat program. The program is very simple. The main purpose is to practice and consolidate what you have learned. Write it here and record the following. Here's the code.
First, the server code:
Then the client code:
Operation effect:
explain:
1. One of the two computers serves as the server, and the computer serving as the server needs two codes. First run the server code and wait for the client machine to connect. After the client runs the client code, it will be prompted that the connection is successful. You can send a message.
2. Before running the code, you need to change the IP address to the current IP address of your computer (computers connected to the Internet by modem, ISDN, ADSL, wired broadband, cell broadband, etc., the IP address assigned to each Internet connection is different, which is called dynamic IP address). If you want to use a computer as the client and server, write the IP address as 127.0.0.1 (127.0.0.1 is the loopback address, referring to the local machine, which is generally used for testing). Run the server code first, and then the client code.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.