客户端通信程序:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
public class MultiTalkClient {
int num;
public static void main(String[] args) {
try{
//首先建立通信所用的套件字
Socket socket = new Socket("127.0.0.1",4700);
//键盘输入流
BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
//通信输出流
PrintWriter os = new PrintWriter(socket.getOutputStream());
//通信输入流
BufferedReader is = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String readline;
readline = sin.readLine();
while(!readline.equals("bye")){
//打印键盘输入的字符串
os.println(readline);
//强制输出
os.flush();
System.out.println("Client:"