LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2009, 09:27 PM   #1
hellgirl
LQ Newbie
 
Registered: Sep 2009
Location: tulsa, ok
Distribution: n/o
Posts: 5

Rep: Reputation: 0
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 */
 
Old 09-14-2009, 10:52 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
open local file error when creating file descriptor hellgirl Linux - Newbie 1 09-14-2009 10:03 PM
source code file 'Not a local file' error with anjuta 2.4.2 PrathuD Linux - Newbie 2 10-24-2008 10:36 AM
How to open an outlook pst local file with Thunderbird cervecero Linux - Newbie 1 08-12-2008 01:01 PM
Geting error loop QFike:getch: File not open QFile:atEnd: this file is not open badgerbox76 Linux - Newbie 6 01-07-2006 05:30 PM
kernel 2.6.10 - error mounting local file systems sirrus_linux Linux - Software 6 02-12-2005 01:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration