Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/neutrino.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <unistd.h>
- int main()
- {
- int rcvid;
- int chid;
- int pid;
- int fd;
- char message [512];
- pid=getpid();
- chid=ChannelCreate(0);
- printf("\nI am Server PID=%d . I create Channel %d\n",pid,chid);
- //fflush(stdout);
- fd = open("server.msg", O_WRONLY|O_CREAT);
- if(fd==-1)printf("\nopen error = %d\n",fd);
- else printf("I was written my PID in file 'server.msg' Ok!\n");
- write (fd,&pid,sizeof(pid));
- close (fd);
- while(1)
- { rcvid=MsgReceive(chid, message, sizeof(message), NULL);
- printf("Recive message, rcvid %x\n:", rcvid);
- printf("Message body: %s\n", message);
- strcpy(message, "This is answer");
- MsgReply(rcvid, 0, message, sizeof(message));
- }
- return(0) ;
- }
Add Comment
Please, Sign In to add comment