EmbLogic's Blog

A chat client ( to chat between two terminals) : Source code snippet

ret_msnd = msgsnd(ret_mget, &m_p, sizeof(struct content), 0);
89 if(strcmp(m_p.con.msg, “exit”) == 10)
90 {
91 printf(“Client 1 says bye\n”);
92 kill(pid, SIGINT); /* kill the child generated for reading the inbox, before parent goe s off */
93 exit(EXIT_SUCCESS);
94 }
95 if(ret_msnd == -1) /* msgsnd fails then kill the child , and the parent.*/
96 {
97 printf(“Failed to send message to write q\n”);
98 perror(“msgsnd”);
99 kill(pid, SIGINT);
100 exit(EXIT_FAILURE);
101 }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>