后台服务端
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public static void main(String[] args) throws IOException {
ServerSocket s = new ServerSocket(1122);//服务器端口号
Socket ss = s.accept();
// 获取IP访问者IP地址
String cip = ss.getInetAddress().getHostAddress();
// 接收信息获取访问姓名身份同时向访问者问好
String msg = String.format("%s:Hello\s\n", "wo", cip);
OutputStream os = ss.getOutputStream();
PrintWriter out = new PrintWriter(os);
out.write(msg);
out.flush();
System.out.println("有人连线了: " + cip);
// 读取信息
InputStream is = ss.getInputStream();
System.out.println(new String(i