1 #include "ace/SOCK_Connector.h"
2 #include "ace/IOStream.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_stdlib.h"
5 #include "ace/OS_NS_unistd.h"
7 // This client is a simple example of using the ACE_IOStream and
8 // ACE_Streambuf_T templates to create an object based on ACE_*_Stream
9 // classes, which mimic a C++ iostream.
12 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
14 #if !defined (ACE_LACKS_ACE_IOSTREAM)
15 const ACE_TCHAR
*server_host
= argc
> 1 ? argv
[1] : ACE_DEFAULT_SERVER_HOST
;
16 u_short server_port
= argc
> 2 ? ACE_OS::atoi (argv
[2]) : ACE_DEFAULT_SERVER_PORT
;
18 ACE_IOStream
<ACE_SOCK_Stream
> server
;
19 ACE_SOCK_Connector connector
;
20 ACE_INET_Addr
addr (server_port
,
23 if (connector
.connect (server
, addr
) == -1)
24 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Buffer up some things to send to the server.
30 server
<< "1 2.3 testing" << endl
;
35 ACE_IOStream_String s1
;
36 ACE_IOStream_String s2
;
37 server
>> s1
>> i
>> f
>> s2
;
39 cerr
<< "Server said:\n\t";
45 if (server
.close () == -1)
46 ACE_ERROR_RETURN ((LM_ERROR
,
51 ACE_UNUSED_ARG (argc
);
52 ACE_UNUSED_ARG (argv
);
53 ACE_ERROR ((LM_ERROR
, "ACE_IOSTREAM not supported on this platform\n"));
54 #endif /* !ACE_LACKS_ACE_IOSTREAM */