answersLogoWhite

0


Best Answer

// File 1: mesg.h

#include

#include

#include

#include

#define MKEY1 4164L

#define MKEY2 4266L

#define PERMS 0666

typedef struct

{

long mtype;

char mdata[50];

}

mesg;

// File 2: Client.c

#include "mesg1.h"

mesg msg1,msg2;

main()

{

int mq_id1,mq_id2;

int n;

if((mq_id1=msgget(MKEY1,PERMS|IPC_CREAT))<0)

{

printf("Client:error creating queue");

exit(1);

}

if((mq_id2=msgget(MKEY2,PERMS|IPC_CREAT))<0)

{

printf("Client:error creating queue");

exit(1);

}

msg1.mtype=10L;

n=read(0,msg1.mdata,50);

msg1.mdata[n]='\0';

msgsnd(mq_id1,&msg1,50,0);

msgrcv(mq_id2,&msg2,50,10L,0);

write(1,msg2.mdata,50);

}

// File 3: Server.c

#include "mesg1.h"

mesg msg;

main(){

int mq_id1,mq_id2;

int n;if( ( mq_id1=msgget(MKEY1,IPC_CREAT|0666) ) < 0){printf("Server:error openenig queue");exit(1);}msgrcv(mq_id1,&msg,50,10L,0);if((mq_id2=msgget(MKEY2,IPC_CREAT|0666))<0){printf("sender:error creating queue");exit(1);}msgsnd(mq_id2,&msg,50,0);}
User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the program for echo server using message queues?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the protocols that send and deliver mail?

An email message is created using a mail client program. This program then sends the message to a server. The server then forwards the message to the recipient's email server, where the message is then supplied to the recipient's email client. It's delivered using a server architectureBy L.S.


What is a Sub-server?

A subserver is a program or process that belongs to a subsystem. A subsystem can have multiple subservers and is responsible for starting, stopping, and providing status of subservers. Subservers can be defined only for a subsystem with a communication type of IPC message queues and sockets. Subsystems using signal communications do not support subservers.


What is a sub server?

A subserver is a program or process that belongs to a subsystem. A subsystem can have multiple subservers and is responsible for starting, stopping, and providing status of subservers. Subservers can be defined only for a subsystem with a communication type of IPC message queues and sockets. Subsystems using signal communications do not support subservers.


Write Client and server program in C language using UDP?

Write and run a client and a server program in C-language using UDP


Is a bukkit server dedicated?

Bukkit is a server managing program, not actually a server itself... You can have a server using Bukkit that's dedicated, On the other hand... you can have a server using Bukkit that isn't.


Why does it say outdated client on your Minecraft server?

Either you don't have the latest minecraft client or the person is using the program session stealer which when someone joins the server it kicks them with the message outdated cleint and takes their il logs onto a specified server your oped the does /op command to gain admin


How the process interact with eatch other?

Processes are interacting each other using Inter Process Communication. In Inter process communication there are shared memory, message queues, pipes there for communication.


Write a program to convert stack into queue using c language?

In order to write a program to convert stack into queue using c language you must be able to identify the proper program. Having a special certification in programing will be beneficial as well to make sure you recognize the proper queues for the programs.


What does it mean if your Lego universe server needs to be updated?

It means that a piece of software you have and run (the Lego Universe server, namely) needs to be updated. If you're connecting to some remote location over the Internet and this message is presented instead, it means that probably you're using a newer version of the program, and the person you're connecting to is using an older version. In that case either you have to use an older client, or the server owner must update the server program. Alternatively you could search for other servers that are compatible with your client version. It all really depends on what you prefer and what you need.


How php program is saved?

It depends on the editor you are using. In most of them is the "Save" or "Save As" option. Some also sends the program directly to a server, using FTP protocol.


What is via vlingo?

via vlingo means the message was sent using the program vlingo. vlingo is a central program you can download ota on cellular phones like blackberries. you are able to open programs and even dictate text messages. when you dictate a message using vlingo and then send it the person reciving it will get the message but at the bottom the words "via vlingo" will apear to inforn you and promote that the person sent that message using that program... hope this helped


Which of the following will happen when a client doesn't know the server address on a network containing a router?

The broadcast message is forwarded using an IP helper address, The client broadcasts to find the server