22.07.2013 Views

Download File

Download File

Download File

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Subject: NETWORK PROGRAMMING LAB Year : 2010<br />

Class : IV B-Tech C.S.E Semester: First<br />

/* file msgrecvQ.c */<br />

# include <br />

# include <br />

# include <br />

# include <br />

# include <br />

# include <br />

//message structure<br />

struct message<br />

{<br />

long msg_type;<br />

char msg_data[1024];<br />

};<br />

int main(int argc,char*argv[])<br />

{<br />

FILE*f;<br />

int x,y,i=0;<br />

char ch;<br />

struct message msg_obj2={100,"M"};<br />

int msg_id;<br />

//creating msg q id<br />

if((msg_id=msgget(1234,0644))==-1)<br />

perror("\nUnable to get message id...");<br />

else<br />

printf("\nmsgid=%d",msg_id);<br />

/* rec message from q*/<br />

if((y=msgrcv(msg_id,&msg_obj2,1024,100,MSG_NOERROR))==-1)<br />

perror(":- msgrcv error...");<br />

else<br />

printf("\nRec Bytes : %d",y);<br />

NP Lab Manual , RNEC page: 15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!