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

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


Category

  ±è¿µ´ë(2003-03-17 02:35:12, Hit : 8402, Vote : 1938
 [System V IPC] msgsnd() function - ¸Þ¼¼ÁöÅ¥

/***************************************************
*   Creat  : 2001. 02. 10  (programed by Cori-Young)
*   Site: http://www.byoneself.co.kr
*   Update :
***************************************************/


#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
#include <string.h>

#define MSGSZ     128

/** Declare the message structure.           */

typedef struct{
        long    mtype;
    char    mtext[MSGSZ];
} message_buf;

main()
{

    int msqid;
    int msgflg = IPC_CREAT | 0666;
    key_t key;
    message_buf sbuf;
    size_t buf_length;

    /** Get the message queue id for the "name" 1234, which was created by the server. */
    key = 1234;

        (void) fprintf(stderr, "nmsgget: Calling msgget(%#lx,%#o)n",key, msgflg);

    if ((msqid = msgget(key, msgflg )) < 0)
    {
        perror("msgget");
        exit(1);
    }
    else
     (void) fprintf(stderr,"msgget: msgget succeeded: msqid = %dn", msqid);

    /** We'll send message type 1   */
    sbuf.mtype = 1;
    (void) fprintf(stderr,"msgget: msgget succeeded: msqid = %dn", msqid);
    (void) strcpy(sbuf.mtext, "In Message");
    (void) fprintf(stderr,"msgget: msgget succeeded: msqid = %dn", msqid);

    buf_length = strlen(sbuf.mtext) ;

    /** Send a message.    */
    if (msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT) < 0) {
       printf ("%d, %d, %s, %dn", msqid, sbuf.mtype, sbuf.mtext, buf_length);
        perror("msgsnd");
        exit(1);
    }

   else
      printf("Message: "%s" Sentn", sbuf.mtext);
    exit(0);
}





62   [Unix/Linux] [¼Ò½º] top for SunOS 5.x (Solaris 2.x)  ±è¿µ´ë 2004/02/20 15502 1343
61   [Unix/Linux] [°­ÁÂ] ÀÎÅÚ ¼¾Æ®¸®³ë ¹«¼±·£ Ä«µå: ndiswrapper  ±è¿µ´ë 2004/06/27 12586 2196
60   [Unix/Linux] [POSIX IPC] mq_send() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 12537 1737
59   [Unix/Linux] [System V IPC] shmget() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 11291 1820
58   [Unix/Linux] [¼Ò½º] top for System V Release 4, Intel or Sparc CPU  ±è¿µ´ë 2004/02/20 11234 1394
57   [Unix/Linux] [Thread] pthread_cond_timedwait() function  ±è¿µ´ë 2003/03/17 11163 1895
56   [Unix/Linux] [Thread] pthread_setschedparam() function  ±è¿µ´ë 2003/03/17 10960 1885
55   [Unix/Linux] [System V IPC] shmctl() function - °øÀ¯¸Þ¸ð¸®  ±è¿µ´ë 2003/03/17 9950 1743
54   [Unix/Linux] [°­ÁÂ] Apache + MySQL + PHP4 + Zend Optimizer ¼³Ä¡  ±è¿µ´ë 2003/04/15 9341 1689
53   [Unix/Linux] [°­ÁÂ] À¥·Î±×ºÐ¼®À» À§ÇÑ Webalizer + GDlib + PNGlib + Zlib ¼³Ä¡  ±è¿µ´ë 2003/05/04 8574 1527
  [Unix/Linux] [System V IPC] msgsnd() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8402 1938
51   [Unix/Linux] [POSIX IPC] mq_receive() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 8329 1841
50   [Unix/Linux] [POSIX IPC] »ý»êÀÚ/¼ÒºñÀÚ - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 8251 5717
49   [Unix/Linux] [¼Ò½º] String Çؽ¬(hash) ÇÔ¼ö  ±è¿µ´ë 2003/07/29 8119 1633
48   [Unix/Linux] [Thread] pthread_cancel() function  ±è¿µ´ë 2003/03/17 8103 3822
47   [Unix/Linux] [Thread] »ý»êÀÚ/¼ÒºñÀÚ 2  ±è¿µ´ë 2003/03/17 8084 1554
46   [Unix/Linux] [System V IPC] msgrcv() function - ¸Þ¼¼ÁöÅ¥  ±è¿µ´ë 2003/03/17 7586 1710
45   [Unix/Linux] [Thread] pthread_attr_getschedparam() function  ±è¿µ´ë 2003/03/17 7087 8237
44   [Unix/Linux] [Thread] Àаí/¾²±â  ±è¿µ´ë 2003/03/17 6909 1546
43   [Unix/Linux] [System V IPC] semget() function - ¼¼¸¶Æ÷¾î  ±è¿µ´ë 2003/03/17 6755 1676

1 [2][3][4]
 

Copyright 1999-2024 Zeroboard / skin by zero