import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.net.Socket; public class Person_Stub implements PersonInterface { Socket socket; public Person_Stub() throws Throwable { // Create our network connection to the skeleton // We use localhost because example will be run on same machine socket = new Socket("localhost",9000); } public int getAge() throws Throwable { // When this method called, stream the method name to the skeleton ObjectOutputStream os = new ObjectOutputStream(socket.getOutputStream()); os.writeObject("age"); os.flush(); ObjectInputStream is = new ObjectInputStream(socket.getInputStream()); return is.readInt(); } public String getName() throws Throwable { // When this method called, stream the method name to the skeleton ObjectOutputStream os = new ObjectOutputStream(socket.getOutputStream()); os.writeObject("name"); os.flush(); ObjectInputStream is = new ObjectInputStream(socket.getInputStream()); return (String)is.readObject(); } }