⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java

📁 java socket 2 for client
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */import java.io.*;import java.net.*;/** * * @author admin */public class client {   // private  String strHost; private static InetAddress host ;   private static final int PORT = 5000;   private static Socket link ;   private static BufferedReader in ;   private static PrintWriter out ;   private static BufferedReader keyboard ;   public static void main(String args[]){      try{         //host = InetAddress.getLocalHost();         //strHost = args[0] ;         host = InetAddress.getByName("169.254.191.122");         link = new Socket(host,PORT);         in = new BufferedReader(new InputStreamReader(link.getInputStream()));         out = new PrintWriter(link.getOutputStream(),true);         keyboard = new BufferedReader(new InputStreamReader(System.in));         String message, response;         do{             System.out.print("Enter message(QUIT to exit)");             message = keyboard.readLine();             out.println(message);             response = in.readLine();             System.out.println(response);         }while(!message.equals("QUIT"));      }catch(UnknownHostException e){          System.out.println("Host ID not found!");      }      catch(IOException e){         e.printStackTrace();      }      finally{         try{            if (link != null){                System.out.println("Closing down connection");                link.close();            }         }         catch(IOException e){             e.printStackTrace();         }      }   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -