client2.cpp

来自「一个开源的网络开发库ACE」· C++ 代码 · 共 50 行

CPP
50
字号
// client2.cpp,v 1.5 2000/11/27 17:56:43 othman Exp

#include "shmem.h"

#include "ace/Log_Msg.h"

#if defined(ACE_LACKS_SYSV_SHMEM)
int
main (int, char *[])
{
  ACE_ERROR_RETURN ((LM_ERROR,
                     "System V Shared Memory not available on this platform\n"),
                    100);
}
#else // ACE_LACKS_SYSV_SHMEM
int
main (int, char *[])
{
  ACE_Shared_Memory_SV shm_client (SHM_KEY,
                                   sizeof (SharedData));

  char *shm = (char *) shm_client.malloc ();

  ACE_DEBUG ((LM_INFO,
              "(%P|%t) Shared Memory is at 0x%x\n",
              shm));

  /*
    More placement new.  The constructor parameter prevents
    clobbering what the server may have written with it's show()
    method.
    */
  SharedData *sd = new (shm) SharedData (0);

  // Show it
  sd->show ();

  // Change it
  sd->set ();

  // Advertise it
  sd->available (1);

  shm_client.close ();

  return 0;
}

#endif /* ACE_LACKS_SYSV_SHMEM */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?