2.4.2. Server Side Stub Sketch

void ServerMainLoop ()
{
  // Keep responding to messages for ever.
  while (true)
  {
    // Wait for client request.
    Message callRequest = Message.receive ();

    // Figure out what function is called.
    String function = callRequest.getString ();

    // The rest of message processing depends on function.
    if (function.equals ("SomeServerFunction")
    {
      SomeParameterTypes parameters = callRequest.getSomeParameterTypes ();
      SomeReturnType result = SomeServerFunction (parameters);

      // Create a message that describes the result.
      Message callResponse = new Message ();
      callResponse.putSomeReturnType (result);

      // Send the response to the client.
      callResponse.send (ClientAddress);
    }
    else ...
  }
}