1
// iostream_client.cpp,v 1.15 2001/06/22 05:55:55 kitty Exp
3
#include "ace/SOCK_Connector.h"
4
#include "ace/IOStream.h"
5
#include "ace/Log_Msg.h"
7
ACE_RCSID(client, iostream_client, "iostream_client.cpp,v 1.15 2001/06/22 05:55:55 kitty Exp")
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.
14
main (int argc, char *argv[])
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;
20
ACE_IOStream<ACE_SOCK_Stream> server;
21
ACE_SOCK_Connector connector;
22
ACE_INET_Addr addr (server_port,
25
if (connector.connect (server, addr) == -1)
26
ACE_ERROR_RETURN ((LM_ERROR,
31
// Buffer up some things to send to the server.
32
server << "1 2.3 testing" << endl;
37
#if defined (ACE_HAS_STRING_CLASS)
38
ACE_IOStream_String s1;
39
ACE_IOStream_String s2;
40
server >> s1 >> i >> f >> s2;
42
cerr << "Server said:\n\t";
50
cerr << "(" << ACE_OS::getpid () << ") Server sent:\n\t";
51
cerr << "(" << i << ") ";
52
cerr << "(" << f << ")" << endl;
53
#endif /* ACE_HAS_STRING_CLASS */
55
if (server.close () == -1)
56
ACE_ERROR_RETURN ((LM_ERROR,
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 */
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 */
78
#endif /* !ACE_LACKS_ACE_IOSTREAM */