package com.huimv.shiwan;

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

public class ClientDemo89 {
    public static void main(String[] args) throws IOException, InterruptedException {
        for (int i = 1; i<= 100000 ;i++){
            System.out.println(i);
            ss();
        }

    }
    public static void  ss() throws IOException, InterruptedException{
        Socket socket = new Socket("192.168.1.3",10088);
        OutputStream os = socket.getOutputStream();
        os.write("hm+158+6+1.0+002d4895+1637+90+2100+10651+1651+4+49+20210118150453+17+end".getBytes());



        // os.close();如果在这里关流,会导致整个socket都无法使用
        socket.shutdownOutput();//仅仅关闭输出流.并写一个结束标记,对socket没有任何影响

        /*InputStream is = socket.getInputStream();
        int b;
        while((b = is.read()) !=-1){
            System.out.println((char) b);
        }*/
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));


        String line;
        while((line = br.readLine())!=null){
            System.out.println(line);
        }
        br.close();
        os.close();

        socket.close();
    }

}
