c - msgtype member in Message Queues -


my server , client structures follows:

 struct server {   long msgtype;   char find[20];  }; struct client {      long msgtype;     char text[200]; }; 

i send message client program common message queue using msgsnd() function. facing difficulty in understanding statement

if msgtyp greater zero, first message of **type** msgtyp received. 

does type mean when use msgrcv() function message received of type long (in case). if how possible receive structure in long?

the argument msgp [of msgrcv() function] points user-defined buffer must contain first field of type 'long int' specify type of message, , data portion hold data bytes of message.

(type 'long' same type 'long int')

the 'msgtype' field used identify message structure. 'msgtype' field followed user-defined data payload.

in example, assign number represent server structure (perhaps '1'), , number represent client structure (perhaps '2').

when message of type 'server' (or '1') sent, 1 endpoint, received endpoint; , 'server' message structure identified value in msgtype ('1').


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -