::: °­ÁÂ/¼Ò½º/¹®¼­ :::

°­ÁÂ/¼Ò½º/¹®¼­ ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã ÀÌ°÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-17 02:30:40, Hit : 8257, Vote : 1822
 [POSIX IPC] mq_receive() function - ¸Þ¼¼ÁöÅ¥

/***************************************************
*--------------------------------------------------
*   posix ipc message queue¸¦ »ç¿ëÇÑ´Ù.
*--------------------------------------------------
*   Creat  : 2001. 02. 10  (programed by Cori-Young )
*   Site: http://www.byoneself.co.kr
*   Update :
*--------------------------------------------------
*   Compile : cc -o recv recv.c -lrt
*--------------------------------------------------
* Machine hardware:   sun4u
* OS version:         5.7
* Processor type:     sparc
* Hardware:           SUNW,Ultra-60
***************************************************/

#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <time.h>
#include <sched.h>
#include <sys/mman.h>
#include <sys/fcntl.h>
#include <signal.h>
#include <mqueue.h>
#include <errno.h>

#define PMODE 0666
extern int errno;
const char *myname = "/qid";
mqd_t mqfd;

void signalCatcher(int sig);

int main()
{
        int i;
        int count=1;
        char msg_buffer[256];
        struct mq_attr attr;
        int open_flags = 0;
                
        ssize_t num_bytes_received = 0;
        
        (void)signal(SIGPIPE, signalCatcher);
        (void)signal(SIGINT, signalCatcher);
        
        
        printf("START OF TEST_RECEIVE n");
                
        attr.mq_maxmsg = 20;
        attr.mq_msgsize = sizeof(msg_buffer);
        attr.mq_flags   = 0;
                
        open_flags = O_RDONLY|O_CREAT;
        

        mqfd = mq_open(myname,open_flags,PMODE,&attr);
        if (mqfd == -1)
        {
                    perror("mq_open failure from main");
                    exit(0);
        };
        
        while(1)
        {
                num_bytes_received = mq_receive(mqfd, msg_buffer, sizeof(msg_buffer), 0);
                    if (num_bytes_received == -1)
              {
                        perror("mq_receive failure on mqfd");
              }
                    else
                    {
                        printf("data read for count %d = %s n",count,msg_buffer);
                        count ++;
                }
        }
        
}

void signalCatcher(int sig)
{
        if (mq_close(mqfd) == -1)
                perror("mq_close failure on mqfd");
        
        if (mq_unlink("myipc") == -1)
                perror("mq_unlink failure in test_ipc");
        
        printf("n===>signal catch end program <===n");
        sleep(1);
        exit(1);
}





62   [Unix/Linux] [°­ÁÂ] ÀÎÅÚ ¼¾Æ®¸®³ë ¹«¼±·£ Ä«µå: ndiswrapper  ±è¿µ´ë 2004/06/27 12541 2189
61   [Unix/Linux] [¼Ò½º] top for System V Release 4, Intel or Sparc CPU  ±è¿µ´ë 2004/02/20 11165 1288
60   [Unix/Linux] [¼Ò½º] top for SunOS 5.x (Solaris 2.x)  ±è¿µ´ë 2004/02/20 15448 1330
59   [Unix/Linux] [¼Ò½º] String Çؽ¬(hash) ÇÔ¼ö  ±è¿µ´ë 2003/07/29 8047 1589
58   [Unix/Linux] [°­ÁÂ] À¥·Î±×ºÐ¼®À» À§ÇÑ Webalizer + GDlib + PNGlib + Zlib ¼³Ä¡  ±è¿µ´ë 2003/05/04 8522 1513
57   [Unix/Linux] [°­ÁÂ] Apache + MySQL + PHP4 + Zend Optimizer ¼³Ä¡  ±è¿µ´ë 2003/04/15 8667 1600
56   [Unix/Linux] [System V IPC] shmop() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 6521 1580
55   [Unix/Linux] [System V IPC] shmctl() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 9882 1704
54   [Unix/Linux] [System V IPC] shmget() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 11191 1789
53   [Unix/Linux] [System V IPC] semop() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 5770 1436
52   [Unix/Linux] [System V IPC] semctl() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 6134 1411
51   [Unix/Linux] [System V IPC] semget() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 6683 1658
50   [Unix/Linux] [System V IPC] msgget() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 6377 1593
49   [Unix/Linux] [System V IPC] msgctl() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 6474 1701
48   [Unix/Linux] [System V IPC] msgrcv() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 7012 1695
47   [Unix/Linux] [System V IPC] msgsnd() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8337 1920
46   [Unix/Linux] [POSIX IPC] »ý»êÀÚ/¼ÒºñÀÚ - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 8117 5691
  [Unix/Linux] [POSIX IPC] mq_receive() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8257 1822
44   [Unix/Linux] [POSIX IPC] mq_send() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 12400 1704
43   [Unix/Linux] [Thread] pthread_cond() function  ±è¿µ´ë 2003/03/17 6626 1688

1 [2][3][4]
 

Copyright 1999-2024 Zeroboard / skin by zero