客户端:
package com.socket.double1;
import java.io.*;
import java.net.Socket;
import java.util.Scanner;
public class MyTcpClient2 {
public static void main(String[] args) {
try {
Socket socket = new Socket("localhost",2019);
while(true){
//发消息
Scanner scanner = new Scanner(System.in);
OutputStream outputStream = socket.getOutputStream();
System.out.print("client send:");
String s = scanner.nextLine();
outputStream.write((s+"\n").getBytes());
System.out.println();
//收消息
InputStream inputStream = socket.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
s = bufferedReader.readLine();
System.out.print("server repl