LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   open error in local file (https://www.linuxquestions.org/questions/programming-9/open-error-in-local-file-755226/)

hellgirl 09-14-2009 09:27 PM

open error in local file
 
I have a error message when I ran my program

that I couldn't open my local file.




I have two files

first one is called client , second one i called server

I am using named pipes to sent a message to the other file called server

used mknod() to create the two named pipes, one for read, one for write



using fork() spawned a child process that executed the server file


both named pipes are opened

the client file got the message from the user

and sent it through the named pipes to the server file

when the server receives the message , it needs to verfify it is correct

in the server file, a local file descriptor is created to read and send
this verifing message when it is not correct




but I am getting an OPEN() error

when I tried to open this shared local array buff

and attach it to a file descriptor
where the message is kept


int main()
{
/*both named pipes are open*/

rfd=open(IFIO1,0);
wfd=open(IFIO2,1);

server(rfd,wfd);
}

void server(int rfd, int wfd)
{
int localfile;
char buff[max];
char buff2[max];

n=read(rfd,buff,max);

if ((localfile = open(buff,0)) < 0) /* this is the error */
{


/* we got a open error */
/* now tell the IPC Client */

sprintf(buff2,"Filename %s Failed on Open Terminating", buff);

n=strlen(buff2);
buff2[n]='\0';


if(write(wfd, buff2, n) != n)
{

/* write error on the IPC descriptor */

nadroj 09-14-2009 10:52 PM

i dont remember how to write FIFOs without going back to my previous work, so i cant tell if you're doing it right or wrong. however, did you check what error corresponds to the value of errno your receiving? use something like "strerr" function.


All times are GMT -5. The time now is 10:14 AM.