basis server creation fail using pipes ???

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2009
Posts: 8
Reputation: defender_ is an unknown quantity at this point 
Solved Threads: 0
defender_ defender_ is offline Offline
Newbie Poster

basis server creation fail using pipes ???

 
0
  #1
May 31st, 2009
Hi,
I am new to c++ programming.... i am working on a example and when ever i run the following code i get error "Server fifo failure" this is an example and should work alright but error making no sense...
I am running this code using sun C++ compiler....

Plzzzz help....
[code]
  1. #include "common.h"
  2. #include <ctype.h>
  3.  
  4. int main()
  5. {
  6. int server_fifo_fd, client_fifo_fd;
  7. struct data_to_pass_st my_data;
  8. int read_res;
  9. char client_fifo[256];
  10. char *tmp_char_ptr;
  11. mkfifo(SERVER_FIFO_NAME, 0777);
  12. server_fifo_fd = open(SERVER_FIFO_NAME, O_RDONLY);
  13. if (server_fifo_fd == -1) {
  14. fprintf(stderr, "Server fifo failure\n");
  15. exit(EXIT_FAILURE);
  16. }
  17.  
  18. sleep(10); /* lets clients queue for demo purposes */
  19. do {
  20. read_res = read(server_fifo_fd, &my_data, sizeof(my_data));
  21. if (read_res > 0) {
  22. tmp_char_ptr = my_data.some_data;
  23. while (*tmp_char_ptr) {
  24. *tmp_char_ptr = toupper(*tmp_char_ptr);
  25. tmp_char_ptr++;
  26. }
  27. sprintf(client_fifo, CLIENT_FIFO_NAME, my_data.client_pid);
  28. client_fifo_fd = open(client_fifo, O_WRONLY);
  29. if (client_fifo_fd != -1) {
  30. write(client_fifo_fd, &my_data, sizeof(my_data));
  31. close(client_fifo_fd);
  32. }
  33. }
  34. } while (read_res > 0);
  35. close(server_fifo_fd);
  36. unlink(SERVER_FIFO_NAME);
  37. exit(EXIT_SUCCESS);
  38. }
Reply With Quote
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 630
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: basis server creation fail using pipes ???

 
0
  #2
May 31st, 2009
The first compiler error I get is that your struct data_to_pass_st isn't defined anywhere. Also, I don't know where common.h is - maybe it is a windows thing?

Dave
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 8
Reputation: defender_ is an unknown quantity at this point 
Solved Threads: 0
defender_ defender_ is offline Offline
Newbie Poster

Re: basis server creation fail using pipes ???

 
0
  #3
May 31st, 2009
Thanks alot for the try.... I have solved my problem.... actually there was some restricted access privileges which were causing some problem....

Originally Posted by daviddoria View Post
The first compiler error I get is that your struct data_to_pass_st isn't defined anywhere. Also, I don't know where common.h is - maybe it is a windows thing?

Dave
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC