bufferediolistener.java

来自「移动Agent编程工具Naplet」· Java 代码 · 共 70 行

JAVA
70
字号
/* @<#>BufferedIOListener.java version 0.0.1, 1/1/2000 * * THIS PROGRAM IS FREE SOFTWARE; YOU CAN DISTRIBUTED IT AND/OR * MODIFY IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE  * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION. * * THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, * BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE  * GNU GENERAL PUBLIC LICENSE FOR MORE DETAILS. * * Copyright (c) 2000 Wayne State University. All Rights Reserved. */package bufferedIO;import java.io.*;import java.util.*;import java.rmi.*;import java.rmi.server.*;import java.net.*;	//For address conversion InetAddress.getByNameimport naplet.*;/** * The <code>BufferedIOListener</code> defines an asynchronous interface for  * remote ICNaplets to call back * * @version 0.0.1, 1/1/2000 * @author C. Xu */public class BufferedIOListener    extends UnicastRemoteObject implements NapletListener{      public BufferedIOListener() throws RemoteException {};      // Collect results from a partition of hosts      public void report( Object result ) 	 throws RemoteException      {	 Hashtable messages = (Hashtable) result;	 for ( Enumeration e = messages.elements(); e .hasMoreElements( ); ) 	 {	    String msg = ( String ) e.nextElement( );//	    System.out.println( msg );	 }		 try 	 {	    String host = UnicastRemoteObject.getClientHost( );	    InetAddress hostAddress = InetAddress.getByName( host );	    String hostName = hostAddress.getHostName( );	    System.out.println( "Message comes from " + hostName ); 	 } 	 catch ( ServerNotActiveException se )	 {	    System.out.println( "report err: " + se.getMessage( ) );	    se.printStackTrace( );	 } 	 catch ( Exception e )	 {	    System.out.println( "report err: " + e.getMessage( ) );	    e.printStackTrace( );	 }	 System.exit( 0 );      }}

⌨️ 快捷键说明

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