~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to examples/IOStream/client/iostream_client.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// iostream_client.cpp,v 1.15 2001/06/22 05:55:55 kitty Exp
2
 
 
3
 
#include "ace/SOCK_Connector.h"
4
 
#include "ace/IOStream.h"
5
 
#include "ace/Log_Msg.h"
6
 
 
7
 
ACE_RCSID(client, iostream_client, "iostream_client.cpp,v 1.15 2001/06/22 05:55:55 kitty Exp")
8
 
 
9
 
// This client is a simple example of using the ACE_IOStream and
10
 
// ACE_Streambuf_T templates to create an object based on ACE_*_Stream
11
 
// classes, which mimic a C++ iostream.
12
 
 
13
 
int
14
 
main (int argc, char *argv[])
15
 
{
16
 
#if !defined (ACE_LACKS_ACE_IOSTREAM)
17
 
  const char *server_host = argc > 1 ? argv[1] : ACE_DEFAULT_SERVER_HOST;
18
 
  u_short server_port = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_DEFAULT_SERVER_PORT;
19
 
 
20
 
  ACE_IOStream<ACE_SOCK_Stream> server;
21
 
  ACE_SOCK_Connector connector;
22
 
  ACE_INET_Addr addr (server_port,
23
 
                      server_host);
24
 
 
25
 
  if (connector.connect (server, addr) == -1)
26
 
    ACE_ERROR_RETURN ((LM_ERROR,
27
 
                       "%p\n",
28
 
                       "open"),
29
 
                      -1);
30
 
 
31
 
  // Buffer up some things to send to the server.
32
 
  server << "1 2.3 testing" << endl;
33
 
 
34
 
  int i;
35
 
  float f;
36
 
 
37
 
#if defined (ACE_HAS_STRING_CLASS)
38
 
  ACE_IOStream_String s1;
39
 
  ACE_IOStream_String s2;
40
 
  server >> s1 >> i >> f >> s2;
41
 
 
42
 
  cerr << "Server said:\n\t";
43
 
  cerr << s1 << " ";
44
 
  cerr << i << " ";
45
 
  cerr << f << " ";
46
 
  cerr << s2 << endl;
47
 
#else
48
 
  server >> i >> f;
49
 
 
50
 
  cerr << "(" << ACE_OS::getpid () << ") Server sent:\n\t";
51
 
  cerr << "(" << i << ") ";
52
 
  cerr << "(" << f << ")" << endl;
53
 
#endif /* ACE_HAS_STRING_CLASS */
54
 
 
55
 
  if (server.close () == -1)
56
 
    ACE_ERROR_RETURN ((LM_ERROR,
57
 
                       "%p\n",
58
 
                       "close"),
59
 
                      -1);
60
 
#else
61
 
  ACE_UNUSED_ARG (argc);
62
 
  ACE_UNUSED_ARG (argv);
63
 
  ACE_ERROR ((LM_ERROR, "ACE_IOSTREAM not supported on this platform\n"));
64
 
#endif /* !ACE_LACKS_ACE_IOSTREAM */
65
 
  return 0;
66
 
}
67
 
 
68
 
 
69
 
#if !defined (ACE_LACKS_ACE_IOSTREAM)
70
 
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
71
 
template class ACE_IOStream <ACE_SOCK_Stream>;
72
 
template class ACE_Streambuf_T <ACE_SOCK_Stream>;
73
 
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
74
 
#pragma instantiate ACE_IOStream <ACE_SOCK_Stream>
75
 
#pragma instantiate ACE_Streambuf_T <ACE_SOCK_Stream>
76
 
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
77
 
 
78
 
#endif /* !ACE_LACKS_ACE_IOSTREAM */