本文整理汇总了C++中ACE_TLI_Stream::send_n方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_TLI_Stream::send_n方法的具体用法?C++ ACE_TLI_Stream::send_n怎么用?C++ ACE_TLI_Stream::send_n使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_TLI_Stream
的用法示例。
在下文中一共展示了ACE_TLI_Stream::send_n方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
if (argc < 2)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Usage: %s filename ")
ACE_TEXT ("[server-host port-number]\n"),
argv[0]),
1);
const ACE_TCHAR *filename = argv[1];
const ACE_TCHAR *host_name = argc < 3 ? ACE_DEFAULT_SERVER_HOST : argv[2];
u_short port = argc < 4 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi (argv[3]);
ACE_TLI_Stream client;
ACE_TLI_Connector con;
int fd;
char buf[BUFSIZ];
if (con.connect (client, ACE_INET_Addr (port, host_name)) == -1)
ACE_OS::t_error ((char *) host_name), ACE_OS::exit (1);
if ((fd = ACE_OS::open (filename, O_RDONLY)) == -1)
ACE_OS::perror (filename), ACE_OS::exit (1);
for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; )
if (client.send_n (buf, n) != n)
ACE_OS::t_error ("client.send error");
if (client.close () == -1)
ACE_OS::t_error ("cli_close"), ACE_OS::exit (1);
return 0;
}
示例2: mmap
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
parse_args (argc, argv);
void *cp;
char buf[BUFSIZ];
ACE_TLI_Stream sc;
ACE_TLI_Connector con;
if (con.connect (sc,
ACE_INET_Addr (port_number,
host_name)) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"open"),
-1);
ACE_Mem_Map mmap (file_name, PROT_READ);
if (mmap (cp) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"mmap"), -1);
// Next, send the file's contents.
if (sc.send_n (cp, mmap.size ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"send_n"), -1);
if (sc.sndrel () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"close_writer"),
-1);
for (int n; (n = sc.recv (buf, sizeof buf)) > 0; )
if (ACE_OS::write (ACE_STDOUT, buf, n) != n)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"write"),
-1);
if (sc.close () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"close"),
-1);
return 0;
}