[공학기술]ICP를 이용한 채팅 프로그램 구현
- 최초 등록일
- 2007.05.12
- 최종 저작일
- 2007.01
- 6페이지/ 한컴오피스
- 가격 1,000원
소개글
➡ 공유메모리, 메시지 큐등 IPC를 이해하고 이를 응용한 프로그램을 구현하여 본다.
☞ 채팅 프로그램은 메시지큐와 공유메모리를 이용하여 작성하였다.
목차
1. 제목
2. 목적
3. 내용
4. 실행결과
5. 첨부(소스코드, 설명)
6. 토의
7. 참고자료
본문내용
⇒ server.c
1 // server.c
2
3 #include <stdio.h>
4 #include <sys/shm.h>
5 #include <sys/msg.h>
6 #include <signal.h>
7 #include <sys/stat.h>
8 #include <errno.h>
9 #include <sys/ipc.h>
10 #include <sys/types.h>
11 #include <unistd.h>
12 #include <stdlib.h>
13 #include <string.h>
14
15 #define MAXSTRING 256
16 #define MSGKEY 1234
17 #define SHMKEY 4321
18 #define FALSE 0
19 #define TRUE 1
20
21 typedef struct{
22 long mtype;
23 char mtext[MAXSTRING];
24 } mymsg_t;
25
26 int main()
27 {
28 void *shared_memory = (void *)0;
29 char *message;
30 int shmid;
31 mymsg_t mymsg;
32 key_t msg_key, shm_key;
33 char flag = 0;
34
35 if((shmid = shmget((key_t)SHMKEY, sizeof(char)*MAXSTRING, IPC_CREAT|0666)) == -1)
36 {
37 perror(
참고 자료
UNIX SYSTEMS Programming (KAY A. AOBBINS STEVEN ROBBINS)