微信小程序,简称小程序,英文名Mini Program,是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或搜一下即可打开应用。小程序是一种不用下载就能使用的应用,也是一项门槛非常高的创新,经过将近两年的发展,已经构造了新的小程序开发环境和开发者生态。
一个很简单的网络聊天小工具,java实现,双向同步发送信息,功能增加中
局域网内ip请自行更改,只要变更client端的localhost ip为另一台pc的ip就行
import java.io.*;
import java.net.Socket;
import java.net.ServerSocket;
import java.net.SocketException;
public class TestServer {
public static void main(String[] args) {
try {
//open the communication port for messenge-transfer
//server socket id:8888
ServerSocket s = new ServerSocket(8888);
//create socket instance and set it be waiting state to accept data
Socket s1 = s.accept();
//original data stream
InputStream is = s1.getInputStream();
OutputStream os = s1.getOutputStream();
DataOutputStream dos = new DataOutputStream(os);
DataInputStream dis = new DataInputStream(is);
System.out.println("Server started!");
new MyServerReader(dis).start();
new MyServerWriter(dos).start();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
class MyServerReader extends Thread {
private DataInputStream dis;
public MyServerReader(DataInputStream dis) {
this.dis = dis;
}
public void run() {
String info;
try {
while (true) {
info = dis.readUTF();
System.out.println("Ta said:" + info);
if (info.equals("bye") 关键词:双向同步聊天小程序[ByJavaOnLinux]完成代码