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

📄 client.java

📁 java的重要部分
💻 JAVA
字号:
// Client.java
/**
 * This a Socket Client program
 * @version 1.0 1999/12/27
 * @author Huang Jian-chang
**/

import java.io.*;
import java.net.*;

public class Client {      
       public static void main(String args[])   {
                try{			
			if (args.length != 1){
				System.out.println("USAGE: java Client servername");				
				return;
			}
			String  connectto= args[0];
                        Socket connection;
			// connect to server
			if(connectto.equals("localhost")){
				connection=new Socket(InetAddress.getLocalHost(),5000);

			}
			else{
				connection=new Socket(InetAddress.getByName(connectto),5000);				
			}			
			DataInputStream  input=new DataInputStream(connection.getInputStream());                       

			// read information from server                        
                        String info;
                        info = input.readUTF();
                        System.out.println(info);
			connection.close();                                                               
		}
		catch(SecurityException e){
			System.out.println("SecurityException when connecting Server!");		
		}		
		catch(IOException e){
			System.out.println("IOException when connecting Server!");   
		}
      	}

}

⌨️ 快捷键说明

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