3 #include "ace/LSOCK_Connector.h"
4 #include "ace/UNIX_Addr.h"
5 #include "ace/Log_Msg.h"
6 #include "ace/OS_main.h"
7 #include "ace/OS_NS_unistd.h"
10 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
12 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
14 const ACE_TCHAR
*rendezvous
= argc
> 1 ? argv
[1] : ACE_DEFAULT_RENDEZVOUS
;
17 ACE_LSOCK_Stream cli_stream
;
18 ACE_LSOCK_Connector con
;
19 ACE_UNIX_Addr
remote_addr (rendezvous
);
21 // Establish the connection with server.
22 if (con
.connect (cli_stream
, remote_addr
) == -1)
23 ACE_ERROR_RETURN ((LM_ERROR
,
25 ACE_TEXT ("connect")),
28 // Send data to server (correctly handles "incomplete writes").
31 (r_bytes
= ACE_OS::read (ACE_STDIN
, buf
, sizeof buf
)) > 0;
33 if (cli_stream
.send_n (buf
, r_bytes
) == -1)
34 ACE_ERROR_RETURN ((LM_ERROR
,
39 // Explicitly close the writer-side of the connection.
40 if (cli_stream
.close_writer () == -1)
41 ACE_ERROR_RETURN ((LM_ERROR
,
43 ACE_TEXT ("close_writer")),
46 // Wait for handshake with server.
47 if (cli_stream
.recv_n (buf
, 1) != 1)
48 ACE_ERROR_RETURN ((LM_ERROR
,
53 // Close the connection completely.
54 if (cli_stream
.close () == -1)
55 ACE_ERROR_RETURN ((LM_ERROR
,
63 ACE_TMAIN (int, ACE_TCHAR
*[])
65 ACE_ERROR_RETURN ((LM_ERROR
,
66 "this platform does not support UNIX-domain sockets\n"), -1);
68 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */