GoConqr has a new look! Let us know what you think.

Notes

EchoClient

David Utza Informatik German 1 page

Content of the notes (1)

Page 1

import java.io.*;

import java.rmi.*;

/**

* Klasse EchoClient

*

* @version 2016-09-09

* @author David

*/

public class EchoClient {

public static final String EXIT = "exit";

public static final String PROMPT_CLIENT = "EchoClient> ";

public static final String PROMPT_SERVER = "EchoServer> ";

public static int uid;

public static void main(String[] args) {

EchoService es = null;

String request = null;

String response = null;

boolean isRunning = false;

BufferedReader in = null;

while (!isRunning) {

try {

es = (EchoService) Naming.lookup("rmi://localhost:1099/testObject");

isRunning = true;

} catch (Exception e) {

// e.printStackTrace();

System.out.println("\nObjekt nicht gefunden. Programm wird beendet.");

}

try {

Thread.sleep(2000);

} catch (Exception e) {

e.printStackTrace();

}

}

// System.exit(1);

try {

isRunning = true;

in = new BufferedReader(new InputStreamReader(System.in));

System.out.print(PROMPT_CLIENT);

request = in.readLine();

while (isRunning) {

if (request != null && !request.equals(EXIT)) {

uid = es.setouruid();

System.out.println(es.getc(uid));

//es.request(request);

//response = es.getResponse();

System.out.println("EchoServer> " + response);

System.out.print(PROMPT_CLIENT);

request = in.readLine();

} else {

isRunning = false;

}

}

}

catch (Exception e) {

e.printStackTrace();

}

}

}

Information

Description
EchoClient
Created by
David Utza
Views
20
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?