コード例 #1
0
ファイル: FIFO-test.cpp プロジェクト: binghuo365/BaseLab
static int
do_parent (const ACE_TCHAR fifo_name[],
           ACE_TCHAR input_filename[])
{
  ACE_FIFO_Send fifo_sender (fifo_name, O_WRONLY | O_CREAT);
  ssize_t len;
  char buf[BUFSIZ];

  if (fifo_sender.get_handle () == ACE_INVALID_HANDLE)
    return -1;

  ACE_HANDLE inputfd =
    ACE_OS::open (input_filename, O_RDONLY);

  if (inputfd == ACE_INVALID_HANDLE)
    return -1;

  // Read from input file and write into input end of the fifo.

  while ((len = ACE_OS::read (inputfd, buf, sizeof buf)) > 0)
    if (fifo_sender.send (buf, len) != len)
      return -1;

  if (len == -1)
    return -1;

  if (fifo_sender.remove () == -1)
    return -1;
  return 0;
}
コード例 #2
0
int 
main (int, char *[])
{
  char buf[] = "hello world";
  ACE_Str_Buf msg (buf, sizeof buf);

  ACE_FIFO_Send_Msg fifo_sender (ACE_DEFAULT_RENDEZVOUS, 
				 O_WRONLY | O_CREAT, 
				 ACE_DEFAULT_FILE_PERMS);

  if (fifo_sender.send (msg) == -1)
    ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send error for fifo"), -1);
  else
    return 0;
}