📄 unbufferediolistener.java
字号:
/* @<#>UnbufferedIOListener.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 unbufferedIO;import java.io.*;import java.util.*;import java.rmi.*;import java.rmi.server.*;import java.net.*; //For address conversion InetAddress.getByNameimport naplet.*;/** * The <code>UnbufferedIOListener</code> defines an asynchronous interface for * remote ICNaplets to call back * * @version 0.0.1, 1/1/2000 * @author C. Xu */public class UnbufferedIOListener extends UnicastRemoteObject implements NapletListener{ public UnbufferedIOListener( ) 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -