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

📄 daytimeclienthelper1.java

📁 JAVA分布式程序学习的课件(全英文)
💻 JAVA
字号:

import java.net.*;

/**
 * This class is a module which provides that application logic
 * for a Daytime Client.
 * @author M. L. Liu
 */
public class DaytimeClientHelper1 {
	
   public static String getTimestamp(String hostName,
                                     String portNum){  
   
      String timestamp = ""; 
      try {      
  		    InetAddress serverHost = InetAddress.getByName(hostName);
  		    int serverPort = Integer.parseInt(portNum);
          // instantiates a datagram socket for both sending
          // and receiving data
   	    MyDatagramSocket mySocket = new MyDatagramSocket();  
          mySocket.sendMessage( serverHost, serverPort, "");
			 // now receive the timestamp
          timestamp = mySocket.receiveMessage();
		    mySocket.close( );

       } // end try
	    catch (Exception ex) {
         System.out.println("There is a problem: " + ex);
	    }
       return timestamp;
   } //end getTimeStamp 
} //end class

⌨️ 快捷键说明

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