Witam. Mam problem a mianowicie jak przesłać strukturę przez kolejkę komunikatów IPC ?
Klient:
struct Message
{
long mtype; // pid servera
struct Player *p;
};
void connect(int msgid, struct Player *p)
{
struct Message m;
m.mtype = 1;
strcpy(p->buffer, "JOIN");
m.p = p;
printf("Wskazuje na : %ld\n", &m.p);
printf("WIADOMOSC: TYP: %ld PID %d STATUS %s\n", m.mtype, m.p->pid, m.p->buffer);
sendMsg(msgid, m);
}
struct Player player;
initialPlayer(&player);
printf("INICJALIZACJA [OK]\n");
connect(msgid, &player);
server
struct Message msg;
while(1)
{
if(msgrcv(msgid, &msg, sizeof(struct Message), 1, 0) <= 0)
continue;
printf("Odebrano : %s\n",msg.p->buffer); // TUTAJ Naruszenie ochrony pamięci (zrzut pamięci)
Jak widać po odebraniu na serwerze dostaje Naruszenie ochrony pamięci (zrzut pamięci) (gdy chce odczytac dane z playera).
Gdy odczytuje mtype to działa (więc jakby nie przesyłało playera)...