thanks, I think I have it from here
thanks, I think I have it from here
Last edited by kbfirebreather; 02-01-2009 at 08:32 PM. Reason: satisfied
Your help message says "filename <input> <output>", but you read from argv[2] and sent to argv[1]?
When you execute the program, in my case I would do..
the input file gets sent to send_file, and the output file gets sent to rcv_fileCode:cse473-ipc inputfile outputfile
is that what you meant? and those are called from inside main, between the respective parent/child
Last edited by kbfirebreather; 02-01-2009 at 02:10 PM. Reason: adding some stuff
Yes, sorry, I was reading top-down but missed the fork.
Well, ^A is the character with value 1, which means instead of printing text, you're printing 1. You probably already knew that. Maybe you should check to see whether you're sending 1's as well. I don't see buf getting null-terminated in readline, which makes fprintf an unpleasant sort of thing.
Well I think my problem is in rcv_file, but I feel like I'm not handling it correctly. When I run the program it always tells me that "rcv_file failed" which is because rcv_file is returning -1, but I'm not to sure why this is happening or how to get around it.
msgrcv sets errno -- so do a perror, as in
which will print the type 2 also -- and see what it says.Code:perror("type 2");
It also may not hurt to use MTYPE and MEND instead of the magic numbers 1 and 2 (supposing that's what they are).
well I believe I am using MTYPE and MEND correct? In send file, when we get to eof that means that the last message is being sent, so when c==1 (eof), i set the .type to MEND, then in rcv file I have to check for the last message which I think is part of my problem.
And you're saying use perror when msgrcv fails? I have 2 msgrcv's in the while loop to try and test for MEND, which one would get the perror?
Any of them that fails -- but I had in mind the one where it returns -1.
You are not receiving any messages of MTYPE and MEND. (Those symbols do not appear in your rcvmsg function at all.) You are receiving messages of type 1 and 2. Those very well may be the same thing -- those are the same thing according to the defines -- but use the defines so that we don't confuse ourselves.
Well the receiving side reads the message which should have the type in the rcvbuf struct that's passed through the function. which is where you have to detect for the last message which is one thing I don't think my code does correctly.
It's in the while loop.
@ tabstop
I see now, you mean at where it does rcvbuf.type == 2, use MEND instead.
I'm gonna edit my post and update my code.