1 #include "ace/OS_main.h"
2 #include "ace/FILE_Addr.h"
3 #include "ace/FILE_Connector.h"
4 #include "ace/FILE_IO.h"
5 #include "ace/Truncate.h"
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_stdio.h"
11 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
13 if (argc
< 3 || argc
> 3)
14 ACE_ERROR_RETURN ((LM_ERROR
,
15 "usage: %s filename string\n",
19 ACE_TCHAR
*readback
= new ACE_TCHAR
[ACE_OS::strlen (argv
[1]) + 1];
21 ACE_FILE_Info fileinfo
;
23 ACE_FILE_Connector con
;
25 if (con
.connect (cli_file
,
26 ACE_FILE_Addr (argv
[1]),
29 O_RDWR
|O_APPEND
|O_CREAT
,
30 ACE_DEFAULT_FILE_PERMS
) == -1)
31 ACE_ERROR_RETURN ((LM_ERROR
,
38 ACE_Utils::truncate_cast
<ssize_t
> (ACE_OS::strlen (argv
[2]) + 1);
40 if (cli_file
.send (argv
[2], len
) != len
)
41 ACE_ERROR_RETURN ((LM_ERROR
,
46 if (cli_file
.get_info (&fileinfo
) == -1)
47 ACE_ERROR_RETURN ((LM_ERROR
,
52 ACE_OS::printf ("fileinfo : mode = %o\nno of links = %lu\nsize = %lu\n",
53 (u_int
) fileinfo
.mode_
& 0777,
54 static_cast<u_long
> (fileinfo
.nlink_
),
55 (u_long
) fileinfo
.size_
);
57 ACE_OFF_T fpos
= cli_file
.tell ();
60 ACE_ERROR_RETURN ((LM_ERROR
,
65 ACE_OS::printf ("current filepointer is at %ld\n",
70 ACE_ERROR_RETURN ((LM_ERROR
,
74 if (cli_file
.recv (readback
, len
) != len
)
75 ACE_ERROR_RETURN ((LM_ERROR
,
80 ACE_OS::printf ("read back :%s\n",
81 ACE_TEXT_ALWAYS_CHAR (readback
));
83 if (cli_file
.close () == -1)
84 ACE_ERROR_RETURN ((LM_ERROR
,