package com; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; import java.net.Socket; public class Client { public static void main(String[] args) throws IOException { getTest(); } public static void getTest() throws IOException{ Socket so = new Socket("127.0.0.1",7456); OutputStream os = so.getOutputStream(); PrintStream ps = new PrintStream(os); InputStream is = so.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); //客户从server的输入流 ps.println("测试发送数据");//推送信息 System.out.println(br.readLine()); //接收信息 ps.close(); so.close(); } }
最近下载更多