[java]代码库
import java.io.*;
02 import java.net.*;
03
04 public class MyServer {
05 public static void main(String[] args) throws IOException {
06 ServerSocket server = new ServerSocket(9999); // 监听9999端口
07 while (true) {
08 Socket client = server.accept();
09 BufferedReader in = new BufferedReader(new InputStreamReader(
10 client.getInputStream()));
11 PrintWriter out = new PrintWriter(client.getOutputStream());
12 while (true) {
13 String str = in.readLine();
14 System.out.println(str);
15 out.println("has receive....");
16 out.flush();
17 if (str.equals("end"))
18 break;
19 }
20 client.close();
21 }
22 }
23 }