I need to execute some examples founded in this page: http://www.chuidiang.com/clinux/ipcs/colas.php
The code for one of them is this one:
#include <iostream.h>
#include <sys/msg.h>
#include <errno.h>
typedef struct Mi_Tipo_Mensaje
{
long Id_Mensaje;
int Dato_Numerico;
char Mensaje[10];
};
main()
{
key_t Clave1;
int Id_Cola_Mensajes;
Mi_Tipo_Mensaje Un_Mensaje;
Clave1 = ftok ("/bin/ls", 33);
if (Clave1 == (key_t)-1)
{
cout << "Error al obtener clave para cola mensajes" << endl;
exit(-1);
}
Id_Cola_Mensajes = msgget (Clave1, 0600 | IPC_CREAT);
if (Id_Cola_Mensajes == -1)
{
cout << "Error al obtener identificador para cola mensajes" << endl;
exit (-1);
}
Un_Mensaje.Id_Mensaje = 1;
Un_Mensaje.Dato_Numerico = 29;
strcpy (Un_Mensaje.Mensaje, "Hola");
msgsnd (Id_Cola_Mensajes, (struct msgbuf *)&Un_Mensaje,
sizeof(Un_Mensaje.Dato_Numerico)+sizeof(Un_Mensaje.Mensaje),
IPC_NOWAIT);
msgrcv (Id_Cola_Mensajes, (struct msgbuf *)&Un_Mensaje,
sizeof(Un_Mensaje.Dato_Numerico) + sizeof(Un_Mensaje.Mensaje),
2, 0);
cout << "Recibido mensaje tipo 2" << endl;
cout << "Dato_Numerico = " << Un_Mensaje.Dato_Numerico << endl;
cout << "Mensaje = " << Un_Mensaje.Mensaje << endl;
msgctl (Id_Cola_Mensajes, IPC_RMID, (struct msqid_ds *)NULL);
}
I'm trying to compile this as suggested in the page I'd mentioned ("make" or "g++ cola1.c -o cola1"), but I get this message:
fatal error: iostream.h: No such file or directory
I know that this problem has been asked quite a lot, but I can't solve it yet, could you please give me some insights? Thank you for your time and disposition,
Sebastián Pavez