package com.zhiwei.readWechat;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Client {

	public static void main(String[] args) throws IOException {
		try {
			Socket socket = new Socket("192.168.0.36", 22222);
			System.out.println("客户端启动成功");
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			PrintWriter write = new PrintWriter(socket.getOutputStream());
			BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			String readline = "", getLine = "";
			// while (!readline.equals("get:end")) {
			readline = br.readLine();
			write.println(readline);
			write.flush();
			if ((getLine = in.readLine()).equals("end:dataSend")) {
				System.out.println("Server:" + getLine);
				// break;
			}
			System.out.println("Server:" + getLine);
			// }
			write.close();
			in.close();
			socket.close();
		} catch (Exception e) {
			System.out.println("can not listen to:" + e);// 出错，打印出错信息
		}
	}

}
