| | |
Named Pipe (FIFO)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hi,
I'm trying to write a program using named pipes, and I'm having trouble opening it. In another program I call this line:
So my named pipe exists and I see it in my list of files. Then I run the program I included below, but I can not get past the open call. Any help would be appreciated for I can not find a lot of resources on this subject.
I'm trying to write a program using named pipes, and I'm having trouble opening it. In another program I call this line:
C++ Syntax (Toggle Plain Text)
mkfifo("./fife", 0777);
So my named pipe exists and I see it in my list of files. Then I run the program I included below, but I can not get past the open call. Any help would be appreciated for I can not find a lot of resources on this subject.
C++ Syntax (Toggle Plain Text)
#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <sys/stat.h> #include <iostream> #define MSGSIZE 14 void main() { char *message = "Hello, world!"; int fd; fd = open("fife", O_WRONLY); // Can not get past this point! cout << "fd: " << fd << endl; if (write(fd, message, MSGSIZE) < 0) cout << "error writing" << endl; close(fd); }
I found out the problem. It waits because it wants another program to handle the other end of the pipe.
I fixed my codes up and I wrote a script like this to fix the problem:
I fixed my codes up and I wrote a script like this to fix the problem:
C++ Syntax (Toggle Plain Text)
#!/bin/bash echo "Running clients..." ./client & ./client & echo "Running server..." ./server # The & runs the program in the background, so you can run another program, playing client and server in the same console
![]() |
Similar Threads
- I need help (Viruses, Spyware and other Nasties)
- I can't remove about:blank (Viruses, Spyware and other Nasties)
- adware.mainsearch - how do you get rid of it? (Viruses, Spyware and other Nasties)
- Another Trojan.Bookmarker.Gen (Viruses, Spyware and other Nasties)
- www.lookfor.cc search still buggin me (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: I Need to Help very Very Fast ( Help Me Please) of Factorial ?
- Next Thread: Debugging - input validation
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int integer java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






