943,751 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 510
  • C++ RSS
May 31st, 2009
0

basis server creation fail using pipes ???

Expand Post »
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]
c++ Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
defender_ is offline Offline
11 posts
since May 2009
May 31st, 2009
0

Re: basis server creation fail using pipes ???

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
Featured Poster
Reputation Points: 437
Solved Threads: 204
Posting Virtuoso
daviddoria is offline Offline
1,968 posts
since Feb 2008
May 31st, 2009
0

Re: basis server creation fail using pipes ???

Thanks alot for the try.... I have solved my problem.... actually there was some restricted access privileges which were causing some problem....

Click to Expand / Collapse  Quote originally posted by daviddoria ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
defender_ is offline Offline
11 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: c++ problem with program
Next Thread in C++ Forum Timeline: destructor question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC