import java.io.*;
import java.net.*;

/***************************************************************************

    MyServerProxy -- The Service's Proxy Class

 ***************************************************************************/

    public class MyServerProxy
      implements MyServerProxyInterface, Serializable
      {
      String sHost;
      int iPort;

      public MyServerProxy (String sHostIn, int iPortIn)
        {
        sHost = sHostIn;
        iPort = iPortIn;
        }

      public String getGreeting ()                  // MyServerProxyInterface
        {
        String s;
        StringBuffer sb;
        byte[] ab;
        int iCount;
        Socket socket;
        InputStream is;

        try
          {
          ab = new byte[1024];
          sb = new StringBuffer ();
          socket = new Socket (sHost, iPort);
          is = socket.getInputStream ();

          while (true)
            {
            iCount = is.read (ab);
            if (iCount < 0) break;
            s = new String (ab, 0, iCount);
            System.out.println ("prox: Received                  --->" 
              + s + "<--- (" + iCount + " bytes)");
            sb.append (s);
            }
          return (sb.toString ());
          }
        catch (Exception e)
          {
          e.printStackTrace ();
          }
        return (null);
        }
      }

