How to pass FIFO path to client process ?


 
Thread Tools Search this Thread
Top Forums Programming How to pass FIFO path to client process ?
# 1  
Old 05-18-2008
How to pass FIFO path to client process ?

Hello everybody !

I have a first program, called "server" which build 2 FIFO's in this way:
Code:
...
#define PERMS 0666
#define FIFO1 "\tmp\cerere"
#define FIFO2 "\tmp\raspuns"
...
mkfifo(FIFO1, PERMS)
mkfifo(FIFO2, PERMS)
...

I want to access these FIFO's in a second separate program, called "client".
I tried to pass the FIFO's path in the client command line, like that:
Quote:
./client \tmp\cerere \tmp\raspuns
but when I tried to open the FIFO's the results were only "Error: No such file or directory."

This is how I transform the command line arguments in "client":
Code:
...
const char* FIFO1 = malloc(sizeof (argv[1]));
strncpy(FIFO1, argv[1], strlen(argv[1]));
const char* FIFO2 = malloc(sizeof (argv[2]));
strncpy(FIFO2, argv[2], strlen(argv[2]));
...

I tried another ways to pass the FIFO's path in the client command line, like that:
Quote:
./client /tmp/cerere /tmp/raspuns
Quote:
./client '\tmp\cerere' '\tmp\raspuns'
Quote:
./client '/tmp/cerere' '/tmp/raspuns'
Quote:
./client "\tmp\cerere" "\tmp\raspuns"
Quote:
./client "/tmp/cerere" "/tmp/raspuns"
I received same error.

If I defined directly the FIFO's path in the source code of "client", like that:
Code:
#define FIFO1 "\tmp\cerere"
#define FIFO2 "\tmp\raspuns"

the "client" works fine.

What is wrong ? May somebody help me ?
Thank you !
# 2  
Old 05-18-2008
One error:
Code:
// this should be
const char* FIFO1 = malloc(strlen (argv[1]));
strncpy(FIFO1, argv[1], strlen(argv[1]));
const char* FIFO2 = malloc(strlen (argv[2]));
strncpy(FIFO2, argv[2], strlen(argv[2]));

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

By pass a process in a Shell Script on file size

I wish to by pass a process if the file is over a certain size? not sure this makes sense current bit of the script below #if we are bypAssing the OCR if ; then echo Bypassing HOTFOLDER OCR HOT_FOLDER_DIR=$BATCH_POST_OCR_DIR; potential change below? would this work would I need... (1 Reply)
Discussion started by: worky
1 Replies

2. Shell Programming and Scripting

Pass path variable on SSH

hi Gurus, Have been struggling with this for a while I have 2 servers , lets say local A and remote B, I need to use both as a part of a pipeline. The folder structure is shared between the two, so I can access the same files and folders from both A and B. When I try to ssh into B from A,... (15 Replies)
Discussion started by: senhia83
15 Replies

3. Shell Programming and Scripting

Pass File name and Directory Path through command to python script

I'm writing python script to get the file-names in the current directory and file sizes .I'm able to get file list and their sizes but unable to pass them through command line. I want to use this script to execute on other directory and pass directory path with file name through command line. Any... (1 Reply)
Discussion started by: etldeveloper
1 Replies

4. Shell Programming and Scripting

Pass return value of a function in background process

Hi, I have created a function f1 defined in script A.sh .I have called this function in background . But I want to use its return value for another function f2 in script A.sh. I tried declaring it as a global variable, yet it always returns the status as 0. Is there any way with which I can get... (7 Replies)
Discussion started by: ashima jain
7 Replies

5. UNIX for Dummies Questions & Answers

Calling a webservice and pass a client certificate

Hi, I am trying to call a http soap webservice using curl command , I have tried the below option but I am getting a failure . curl -H "Content-Type: text/xml; charset=utf-8" -H SOAPAction:" -d @Request.xml -X POST... (1 Reply)
Discussion started by: IshuGupta
1 Replies

6. AIX

tprof, truncate the process path

Hi, i tryed tprof -skex sleep 6 but... Process PID TID Total Kernel User Shared Other Java ======= === === ===== ====== ==== ====== ===== ==== wait 57372 77863 31.31 31.31 0.00 0.00 0.00 0.00 wait ... (1 Reply)
Discussion started by: zanac
1 Replies

7. Shell Programming and Scripting

How to pass data from server (CGI script) to client (html page)

Hi I know how to pass data from client side (html file) to server using CGI script (POST method). I also know how to re-create the html page from server side after receiving the data (using printf). However I want to write static pages on client side (only the structure), and only to pass... (0 Replies)
Discussion started by: naamabm
0 Replies

8. Programming

Client server communication using FIFO.

Hiii..... I need a client server communication using a FIFO. Sever is contacted by multiple clients.Each client writes its request to a FIFO.The server replies back to the client through a client specific FIFO. give any link to sample FIFO programs.......... Thanking you KRISH:cool: (1 Reply)
Discussion started by: krishnampkkm
1 Replies

9. UNIX Desktop Questions & Answers

Does it require each x-client sould run in separate process?

Hi Every One, I got a Basic doubts about clients on X-Server environment. 1) First of all what is mend by one client. (as per my understanding one application which is connected to X-server). 2) if i say two clients connected to my X-Server from the same machine, does it mean that two... (0 Replies)
Discussion started by: ps_sureshreddi
0 Replies

10. Programming

i want to pass the connect fd to child process,how can i do ti?

i write a function using to pass the socket connected fd to child process in the sco unix open server 5.0.5,but in fact i execute the program calling the fuction,system report send the fd error: Jul 12 12:15 send_fd.c: send_fd sendmsg to sd error how can i solve the problem ,please help me!!!... (6 Replies)
Discussion started by: hit
6 Replies
Login or Register to Ask a Question