open local file error when creating file descriptor
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 is called server
I am using named pipes to sent a message from client to the other file called server
in client I
used mknod() to create the two named pipes, one for read, one for write
and created new thread in client
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
why do I get this error
in server file
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) /*error line I have question*/
{
/* 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 */
|