FileDocCategorySizeDatePackage
PingServer.javaAPI DocExample1114Thu Nov 08 00:23:50 GMT 2001com.ora.rmibook.chapter8.stuckconstructor

PingServer

public class PingServer extends UnicastRemoteObject implements Ping

Fields Summary
Constructors Summary
public PingServer()

        super (10000); 	// our well-known port.
        storeStubInTempDirectory();
        while (true) {
            try {
                Thread.sleep(5000);
            } catch (Exception e) {
            }
        }
    
Methods Summary
public voidping()

        System.out.println("Ping!");
    
private voidstoreStubInTempDirectory()

        try {
            RemoteStub stub = (RemoteStub) toStub(this);
            FileOutputStream file = new FileOutputStream("C:\\temp\\ping_stub");
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(file);

            objectOutputStream.writeObject(stub);
            objectOutputStream.close();
        } catch (Exception e) {
            System.out.println("Error writing stub to file");
            e.printStackTrace();
        }