package com.lovecoding.day22.tcp02;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

//客户端
public class ClentTCP {

    public static void main(String[] args) throws IOException {

        while (true){
            //192.168.18.31
            Socket socket = new Socket("192.168.18.10",8888);
            //Scanner
            OutputStream outputStream = socket.getOutputStream();
            //发送数据
            PrintStream printStream = new PrintStream(outputStream);
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入文字！");
            String next = sc.next();

            if (next.equals("stop")){
                break;
            }
            printStream.write(next.getBytes());
        }
    }
}
