main.cpp 630 B

1234567891011121314151617181920212223242526272829303132
  1. #include <QCoreApplication>
  2. #include "appserver.h"
  3. #include "../ytDMPServerDog/dogshm.h"
  4. ServerDogShm *dogshm;
  5. bool load_shm()
  6. {
  7. int shmid;
  8. key_t key;
  9. if((key=ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1){
  10. return false;
  11. }
  12. if((shmid=shmget(key,sizeof(ServerDogShm),IPC_CREAT|0666))==-1){
  13. return false;
  14. }
  15. dogshm=static_cast<ServerDogShm*>(shmat(shmid,nullptr,0));
  16. return true;
  17. }
  18. int main(int argc, char *argv[])
  19. {
  20. QCoreApplication a(argc, argv);
  21. if(load_shm()){
  22. AppServer *server = new AppServer(nullptr);
  23. server->start();
  24. }
  25. return a.exec();
  26. }