mq_client.cpp
来自「ace开发环境 用来开发网络程序 其运用了设计模式、多平台、C++等多种知识」· C++ 代码 · 共 56 行
CPP
56 行
// $Id: MQ_Client.cpp 78634 2007-06-28 14:14:06Z johnnyw $#include "ace/SV_Message_Queue.h"#include "test.h"// FUZZ: disable check_for_streams_include#include "ace/streams.h"#include "ace/Malloc.h"#include "ace/OS_NS_stdio.h"#include "ace/OS_NS_unistd.h"#include "ace/OS_NS_stdlib.h"ACE_RCSID(SV_Message_Queues, MQ_Client, "$Id: MQ_Client.cpp 78634 2007-06-28 14:14:06Z johnnyw $")#if defined (ACE_HAS_SYSV_IPC) && !defined(ACE_LACKS_SYSV_SHMEM)intACE_TMAIN (int, ACE_TCHAR *[]){ long pid = long (ACE_OS::getpid ()); ACE_SV_Message_Queue msgque (SRV_KEY); Message_Block send_msg (SRV_ID, pid, ACE_OS::cuserid (static_cast<char *> (0)), "did you get this?"); Message_Block recv_msg (pid); if (msgque.send (send_msg, send_msg.length ()) < 0) ACE_OS::perror ("msgque.send"), ACE_OS::exit (1); if (msgque.recv (recv_msg, sizeof (Message_Data), recv_msg.type ()) < 0) ACE_OS::perror ("msgrcv"), ACE_OS::exit (1); cout << "a message of length " << recv_msg.length () << " received from server " << recv_msg.pid () << " (user " << recv_msg.user () << "): " << recv_msg.text () << "\n"; return 0;}#elseint ACE_TMAIN (int, ACE_TCHAR *[]){ ACE_ERROR ((LM_ERROR, "SYSV IPC, or SYSV SHMEM is not supported on this platform\n")); return 0;}#endif /* ACE_HAS_SYSV_IPC && !ACE_LACKS_SYSV_SHMEM*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?