1 #include "ace/OS_NS_fcntl.h"
2 #include "ace/LSOCK_Connector.h"
3 #include "ace/UNIX_Addr.h"
4 #include "ace/Log_Msg.h"
5 #include "ace/OS_main.h"
8 #if defined (ACE_HAS_MSG) && !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
12 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
14 const ACE_TCHAR
*file_name
= argc
> 1 ? argv
[1] : ACE_TEXT ("./local_data");
15 const ACE_TCHAR
*rendezvous
= argc
> 2 ? argv
[2] : ACE_DEFAULT_RENDEZVOUS
;
17 ACE_LSOCK_Stream cli_stream
;
18 ACE_UNIX_Addr
addr (rendezvous
);
20 // Establish the connection with server.
21 ACE_LSOCK_Connector connector
;
23 if (connector
.connect (cli_stream
, addr
) == -1)
24 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p"), ACE_TEXT ("connect")), -1);
26 ACE_HANDLE handle
= ACE_OS::open (file_name
, O_RDONLY
);
28 if (handle
== ACE_INVALID_HANDLE
)
29 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p"), ACE_TEXT ("open")), -1);
31 // Send handle to server (correctly handles incomplete writes).
32 if (cli_stream
.send_handle (handle
) == -1)
33 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p"), ACE_TEXT ("send")), -1);
36 ssize_t n
= cli_stream
.recv (buf
, sizeof buf
);
39 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p"), ACE_TEXT ("recv")), -1);
41 //FUZZ: disable check_for_lack_ACE_OS
42 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("server shutdown (bug in kernel?)\n")));
43 //FUZZ: enable check_for_lack_ACE_OS
45 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("server %*C shutdown\n"), n
, buf
));
47 // Explicitly close the connection.
48 if (cli_stream
.close () == -1)
49 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p"), ACE_TEXT ("close")), -1);
54 int ACE_TMAIN (int, ACE_TCHAR
*[])
56 ACE_ERROR_RETURN ((LM_ERROR
,
57 ACE_TEXT ("your platform must support sendmsg/recvmsg to run this test\n")), -1);
59 #endif /* ACE_HAS_MSG */