CS2257

Operating System Lab

Exp# 5c

Chat Messaging

Aim To exchange message between server and client using message queue.

Algorithm Server 1. 2. 3. 4. 5.

6. 7.

Decalre a structure mesgq with type and text fields. Initialize key to 2013 (some random value). Create a message queue using msgget with key & IPC_CREAT as parameter. a. If message queue cannot be created then stop. Initialize the message type member of mesgq to 1. Do the following until user types Ctrl+D a. Get message from the user and store it in text member. b. Delete the newline character in text member. c. Place message on the queue using msgsend for the client to read. d. Retrieve the response message from the client using msgrcv function e. Display the text contents. Remove message queue from the system using msgctl with IPC_RMID as parameter. Stop

Client 1. 2. 3. 4.

5. 6.

Decalre a structure mesgq with type and text fields. Initialize key to 2013 (same value as in server). Open the message queue using msgget with key as parameter. a. If message queue cannot be opened then stop. Do while the message queue exists a. Retrieve the response message from the server using msgrcv function b. Display the text contents. c. Get message from the user and store it in text member. d. Delete the newline character in text member. e. Place message on the queue using msgsend for the server to read. Print "Server Disconnected". Stop

Result Thus chat session between client and server was done using message queue.

http://cseannauniv.blogspot.com

Vijai Anand

CS2257

Operating System Lab

Program Server /* Server chat process - srvmsg.c */ #include #include #include #include #include #include



struct mesgq { long type; char text[200]; } mq; main() { int msqid, len; key_t key = 2013; if((msqid = msgget(key, 0644|IPC_CREAT)) == -1) { perror("msgget"); exit(1); } printf("Enter text, ^D to quit:\n"); mq.type = 1; while(fgets(mq.text, sizeof(mq.text), stdin) != NULL) { len = strlen(mq.text); if (mq.text[len-1] == '\n') mq.text[len-1] = '\0'; msgsnd(msqid, &mq, len+1, 0); msgrcv(msqid, &mq, sizeof(mq.text), 0, 0); printf("From Client: \"%s\"\n", mq.text); } msgctl(msqid, IPC_RMID, NULL); }

http://cseannauniv.blogspot.com

Vijai Anand

CS2257

Operating System Lab

Client /* Client chat process - climsg.c */ #include #include #include #include #include #include



struct mesgq { long type; char text[200]; } mq; main() { int msqid, len; key_t key = 2013; if ((msqid = msgget(key, 0644)) == -1) { printf("Server not active\n"); exit(1); } printf("Client ready :\n"); while (msgrcv(msqid, &mq, sizeof(mq.text), 0, 0) != -1) { printf("From Server: \"%s\"\n", mq.text); fgets(mq.text, sizeof(mq.text), stdin); len = strlen(mq.text); if (mq.text[len-1] == '\n') mq.text[len-1] = '\0'; msgsnd(msqid, &mq, len+1, 0); } printf("Server Disconnected\n"); }

http://cseannauniv.blogspot.com

Vijai Anand

CS2257

Operating System Lab

Output

Server $ gcc srvmsg.c -o srvmsg $ ./srvmsg Enter text, ^D to quit: hi From Client: "hello" Where r u? From Client: "I'm where i am" bye From Client: "ok" ^D

Client $ gcc climsg.c -o climsg $ ./climsg Client ready: From Server: "hi" hello From Server: "Where r u?" I'm where i am From Server: "bye" ok Server Disconnected

http://cseannauniv.blogspot.com

Vijai Anand

Chat Messaging

To exchange message between server and client using message queue. Algorithm. Server. 1. Decalre a structure mesgq with type and text fields. 2. Initialize key to 2013 (some random value). 3. Create a message queue using msgget with key & IPC_CREAT as parameter. a. If message queue cannot be created then stop.

11KB Sizes 1 Downloads 338 Views

Recommend Documents

Remind Messaging kure.pdf
Page 1 of 1. Remind Messaging. We will be using the class website www.sciguy.ca and the Remind messaging service to share information with. students and parents. What is remind and why is it safe? Remind is a free, safe, and simple messaging tool tha

messaging sale offering - IAM Market
Subject matter includes, but is not limited to, availability status management. .... for management of on-call messaging ... communications among a largest.

Chit Chat Topics.pdf
What would you keep in a treasure chest? – Do you like to spend or save money? Why? – What is something you love to do with your mother? Page 1 of 3 ...

Video Chat Planner.pdf
Video Chat Planner.pdf. Video Chat Planner.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Video Chat Planner.pdf. Page 1 of 1.

datin chat-split.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. datin chat-split.

messaging sale offering - IAM Market
Suggesting a time for live ... initiate an instant messaging session with the user. ... of the group of first users cannot initiate the new instant messaging session.

Understanding Instant Messaging Traffic Characteristics
stant messaging systems, AOL Instant Messenger (AIM) and ... video and voice chats and file attachments, traffic volume ..... Breakdown of IM message types.

Cri-du-Chat syndrome.pdf
Joanna Tatith Pereira. Renata Schlesner .... cheeks and tongue, and absence of lip seal (Figure 1a-b). Dental ... Displaying Cri-du-Chat syndrome.pdf. Page 1 of ...

Hangouts Chat Cheat Sheet - G Suite
Send messages to individuals or groups, set up rooms for project teams, and have multiple conversations on different topics inside rooms. 1 Send direct messages to an individual or a group. 2 Create a room. 3 Work with Chat. Learning Center gsuite.go

Firebase Cloud Messaging for Web & Settle Up
Users already received these notifications in the app, but. Settle Up wanted their web users to have the same experience. They also wanted a unified solution ...

Chat to Succeed
compares a technical network to a communication network and identifies gaps where a coordination need exists, but no communication fills the gap. Recent ...

Comparing Postini and Leading Messaging Security ...
efficiency and the amount of technical support that the solution required. Further, Postini's results for the amount of IT time required to manage the system was decidely better than the average of the other systems, not surprising given that most of

Launch of RabbitMQ Open Source Enterprise Messaging
deploy' features and fixes whilst managing consistent user service level ... Page 3 ... RabbitMQ will be integrated with other networks via Enterprise Service.

Firebase Cloud Messaging for Web & Alibaba.com
ALIBABA.COM. 20% + open rate. 4X higher engagement for users who receive web notifications than users who visit the website directly. “We were unable to ...

Security Whitepaper: Google Apps Messaging and ... - Cryptome
to quickly recognize, analyze, and remediate information security threats. 3 ... web frontend service would make a remote procedure call to a Gmail backend ..... it simply, Google does not own customer data, and we believe it should stay that way. ..

support.google.com-Chat with your customers.pdf
support.google.com-Chat with your customers.pdf. support.google.com-Chat with your customers.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying ...

Social learning by chit-chat
Dec 9, 2010 - Motivating examples. Results ... ANZ's Director of Marketing explained that half of the ... Individuals are not relying exclusively on their social.

Firebase Cloud Messaging for Web & AliExpress
Firebase Cloud Messaging for Web & AliExpress. ALIEXPRESS. 93.4% higher open rate vs. app notifications. 178% increase in conversion compared to mSite ...

Social learning by chit-chat
Keywords: social learning, network, speed of learning, mean preserving spread .... the effectiveness of the influencer is the most connected site in the network. .... term independently drawn for each i from a common normal distribution with mean 0 .

CHEAHA CHAT SENIOR EDIt SUPPLEMENT.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. CHEAHA CHAT SENIOR EDIt SUPPLEMENT.pdf. CHEAHA CHAT SENIOR EDIt SUPPLEMENT.pdf. Open. Extract. Open with. Si

HOA HOC CHAT RAN.pdf
Loading… Page 1. Whoops! There was a problem loading more pages. HOA HOC CHAT RAN.pdf. HOA HOC CHAT RAN.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying HOA HOC CHAT RAN.pdf.