Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / examples / IPC_SAP / TLI_SAP / ftp-client.cpp
blob48f11eea4b71aba5869aa3dba042c43c28263368
1 #include "ace/TLI_Connector.h"
2 #include "ace/Log_Msg.h"
3 #include "ace/OS_NS_fcntl.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_stdlib.h"
6 #include "ace/OS_NS_unistd.h"
9 #if defined (ACE_HAS_TLI)
11 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
13 if (argc < 2)
14 ACE_ERROR_RETURN ((LM_ERROR,
15 ACE_TEXT ("Usage: %s filename ")
16 ACE_TEXT ("[server-host port-number]\n"),
17 argv[0]),
18 1);
20 const ACE_TCHAR *filename = argv[1];
21 const ACE_TCHAR *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2];
22 u_short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]);
24 ACE_TLI_Stream client;
25 ACE_TLI_Connector con;
26 int fd;
27 char buf[BUFSIZ];
29 if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1)
30 ACE_OS::t_error ((char *) host_name), ACE_OS::exit (1);
32 if ((fd = ACE_OS::open (filename, O_RDONLY)) == -1)
33 ACE_OS::perror (filename), ACE_OS::exit (1);
35 for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; )
36 if (client.send_n (buf, n) != n)
37 ACE_OS::t_error ("client.send error");
39 if (client.close () == -1)
40 ACE_OS::t_error ("cli_close"), ACE_OS::exit (1);
42 return 0;
44 #else
45 int ACE_TMAIN (int, ACE_TCHAR *[])
47 ACE_ERROR_RETURN ((LM_ERROR,
48 ACE_TEXT ("your platform isn't configured to support TLI\n")),
49 1);
51 #endif /* ACE_HAS_TLI */