summaryrefslogtreecommitdiff
path: root/ACE/apps/drwho/client.cpp
blob: e7768b9188eb794a0bfe4112d0c8a478122c5f43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

//=============================================================================
/**
 *  @file    client.cpp
 *
 *  $Id$
 *
 *  Client driver program for drwho.
 *
 *
 *  @author Douglas C. Schmidt
 */
//=============================================================================


#include "ace/Log_Msg.h"

#include "Options.h"
#include "SML_Client.h"
#include "SMR_Client.h"
#include "ace/OS_Memory.h"

// Factory function.

static SM_Client *
make_client (void)
{
  SM_Client *client = 0;

  if (Options::get_opt (Options::REMOTE_USAGE) == 0)
    ACE_NEW_RETURN (client,
                    SML_Client,
                    0);
  else
    ACE_NEW_RETURN (client,
                    SMR_Client (Options::port_number),
                    0);
  return client;
}

int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  Options::set_options (argc, argv);

  SM_Client *sm_client = make_client ();

  if (sm_client->send () < 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       Options::program_name),
                      -1);

  if (sm_client->receive (Options::max_server_timeout) < 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "%p\n",
                       Options::program_name),
                      -1);

  sm_client->process ();

  return 0;
}