Download File
Download File
Download File
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 />
WEEK 3:<br />
Aim: Implement file transfer using Message Queue form of IPC /* file msgsendQ.c */<br />
# include <br />
# include <br />
# include <br />
# include <br />
# include <br />
# include <br />
struct message<br />
{<br />
long msg_type;<br />
char msg_data[1024];<br />
};<br />
int main(int arc,char*argv[])<br />
{<br />
//message structure<br />
FILE*f;<br />
int x,y,i=0;<br />
char ch;<br />
int key=1234;<br />
int msg_id;<br />
struct message msg_obj1={100,"I"};<br />
//function to put file to message Q<br />
if((f=fopen(argv[1],"r"))==NULL)<br />
perror("\nUnable to open file for reading...");<br />
else<br />
{<br />
while((ch=getc(f))!=EOF)<br />
{<br />
msg_obj1.msg_data[i++]=ch; //writing to msg_data<br />
}<br />
NP Lab Manual , RNEC page: 12