哦买噶忘了发代码了不好意思
- import java.net.*;
- import java.io.*;
- class TransClient {
- public static void main(String[] args)throws Exception{
- Socket s=new Socket("192.168.191.1",10006);
- BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in));
- BufferedWriter buOut=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
- BufferedReader buIn=new BufferedReader(new InputStreamReader(s.getInputStream()));
- String line=null;
- while((line=bufr.readLine())!=null){
- if("line".equals("over"))
- break;
- buOut.write(line);
- buOut.newLine();
- buOut.flush();
- String str=buIn.readLine();
- System.out.println("server:"+str);
- }
- bufr.close();
- s.close();
- }
- }
- class TransServer {
- public static void main(String[] args)throws Exception{
- ServerSocket ss=new ServerSocket(10006);
- Socket s=ss.accept();
- BufferedReader buIn=new BufferedReader(new InputStreamReader(s.getInputStream()));
- BufferedWriter buOut=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
- String line=null;
- while((line=buIn.readLine())!=null){
- buOut.write(line.toUpperCase());
- buOut.newLine();
- buOut.flush();
- }
- s.close();
- ss.close();
- }
- }
复制代码
|