C/S最简单的socket通信
c:
Socket socket = new Socket(InetAddress.getLocalHost(), 111);
PrintStream pStream = new PrintStream(socket.getOutputStream());
pStream.print("hello");
socket.close();
s:
ServerSocket ssocket = new ServerSocket(111);
Socket socket = ssocket.accept();
BufferedReader bReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String string = bReader.readLine();
System.out.println("服务器接收到的数据时:" + string);