Skip to main content
edited tags
Link
tshepang
  • 12.5k
  • 25
  • 98
  • 140
added 458 characters in body
Source Link
ICantNameMe
  • 93
  • 1
  • 1
  • 7

'Server' program side:

#define RESP_FIFO_NAME "response" /* Global Variables */ char *cmdfifo = CMD_FIFO_NAME; /* Name of command FIFO. */ char *respfifo = RESP_FIFO_NAME; /* Name of response FIFO. */ int main(int argc, char* argv[]) { int infd, outfd; /* FIFO file descriptors. */ ... // blah blah other code here /* Create command FIFO. */ if (mkfifo(cmdfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", CMD_FIFO_NAME); exit(1); } } /* Create response FIFO. */ if (mkfifo(respfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } /* Open the command FIFO for non-blocking reading. */ if ((infd = open(cmdfifo, O_RDONLY | O_NONBLOCK)) == -1) { fprintf(stderr, "Server: Failed to open %s FIFO.\n", CMD_FIFO_NAME); exit(1); } /* Open the response FIFO for non-blocking writes. */ if ((outfd = open(respfifo, O_WRONLY | O_NONBLOCK)) == -1) { fprintf(stderr, "Server: Failed to open %s FIFO.\n", RESP_FIFO_NAME); perror(RESP_FIFO_NAME); exit(1); } 

The program prints an output of:

Server: Couldn’t create response FIFO. 

I understand very little on FIFOs as my professor didn't teach it. This was all I was able to manage from reading his examples and lecture notes. I tried without O_NONBLOCK flag but that just causes the program to hang, so it is required. I don't understand why the read FIFO is fine but the write FIFO fails to open.

'Server' program side:

#define RESP_FIFO_NAME "response" /* Global Variables */ char *cmdfifo = CMD_FIFO_NAME; /* Name of command FIFO. */ char *respfifo = RESP_FIFO_NAME; /* Name of response FIFO. */ int main(int argc, char* argv[]) { int infd, outfd; /* FIFO file descriptors. */ ... // blah blah other code here /* Create command FIFO. */ if (mkfifo(cmdfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", CMD_FIFO_NAME); exit(1); } } /* Create response FIFO. */ if (mkfifo(respfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } 

The program prints an output of:

Server: Couldn’t create response FIFO. 

I understand very little on FIFOs as my professor didn't teach it. This was all I was able to manage from reading his examples and lecture notes. I tried without O_NONBLOCK flag but that just causes the program to hang, so it is required. I don't understand why the read FIFO is fine but the write FIFO fails to open.

'Server' program side:

#define RESP_FIFO_NAME "response" /* Global Variables */ char *cmdfifo = CMD_FIFO_NAME; /* Name of command FIFO. */ char *respfifo = RESP_FIFO_NAME; /* Name of response FIFO. */ int main(int argc, char* argv[]) { int infd, outfd; /* FIFO file descriptors. */ ... // blah blah other code here /* Create command FIFO. */ if (mkfifo(cmdfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", CMD_FIFO_NAME); exit(1); } } /* Create response FIFO. */ if (mkfifo(respfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } /* Open the command FIFO for non-blocking reading. */ if ((infd = open(cmdfifo, O_RDONLY | O_NONBLOCK)) == -1) { fprintf(stderr, "Server: Failed to open %s FIFO.\n", CMD_FIFO_NAME); exit(1); } /* Open the response FIFO for non-blocking writes. */ if ((outfd = open(respfifo, O_WRONLY | O_NONBLOCK)) == -1) { fprintf(stderr, "Server: Failed to open %s FIFO.\n", RESP_FIFO_NAME); perror(RESP_FIFO_NAME); exit(1); } 

The program prints an output of:

Server: Couldn’t create response FIFO. 

I understand very little on FIFOs as my professor didn't teach it. This was all I was able to manage from reading his examples and lecture notes. I tried without O_NONBLOCK flag but that just causes the program to hang, so it is required. I don't understand why the read FIFO is fine but the write FIFO fails to open.

added 34 characters in body
Source Link
ICantNameMe
  • 93
  • 1
  • 1
  • 7

'Server' program side:

#define RESP_FIFO_NAME "response" /* Global Variables */ char *cmdfifo = CMD_FIFO_NAME; /* Name of command FIFO. */ char *respfifo = RESP_FIFO_NAME; /* Name of response FIFO. */ int main(int argc, char* argv[]) { int infd, outfd; /* FIFO file descriptors. */ ... // blah blah other code here /* Create command FIFO. */ if (mkfifo(cmdfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", CMD_FIFO_NAME); exit(1); } } /* Create response FIFO. */ if (mkfifo(respfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } 

The program prints an output of:

Server: Couldn’t create <RESP_FIFO_NAME>response FIFO. 

I understand very little on FIFOs as my professor didn't teach it. This was all I was able to manage from reading his examples and lecture notes. I tried without O_NONBLOCK flag but that just causes the program to hang, so it is required. I don't understand why the read FIFO is fine but the write FIFO fails to open.

'Server' program side:

/* Global Variables */ char *cmdfifo = CMD_FIFO_NAME; /* Name of command FIFO. */ char *respfifo = RESP_FIFO_NAME; /* Name of response FIFO. */ int main(int argc, char* argv[]) { int infd, outfd; /* FIFO file descriptors. */ ... // blah blah other code here /* Create command FIFO. */ if (mkfifo(cmdfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", CMD_FIFO_NAME); exit(1); } } /* Create response FIFO. */ if (mkfifo(respfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } 

The program prints an output of:

Server: Couldn’t create <RESP_FIFO_NAME> FIFO 

I understand very little on FIFOs as my professor didn't teach it. This was all I was able to manage from reading his examples and lecture notes. I tried without O_NONBLOCK flag but that just causes the program to hang, so it is required. I don't understand why the read FIFO is fine but the write FIFO fails to open.

'Server' program side:

#define RESP_FIFO_NAME "response" /* Global Variables */ char *cmdfifo = CMD_FIFO_NAME; /* Name of command FIFO. */ char *respfifo = RESP_FIFO_NAME; /* Name of response FIFO. */ int main(int argc, char* argv[]) { int infd, outfd; /* FIFO file descriptors. */ ... // blah blah other code here /* Create command FIFO. */ if (mkfifo(cmdfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", CMD_FIFO_NAME); exit(1); } } /* Create response FIFO. */ if (mkfifo(respfifo, FIFO_MODE) == -1) { if (errno != EEXIST) { fprintf(stderr, "Server: Couldn’t create %s FIFO.\n", RESP_FIFO_NAME); exit(1); } } 

The program prints an output of:

Server: Couldn’t create response FIFO. 

I understand very little on FIFOs as my professor didn't teach it. This was all I was able to manage from reading his examples and lecture notes. I tried without O_NONBLOCK flag but that just causes the program to hang, so it is required. I don't understand why the read FIFO is fine but the write FIFO fails to open.

Source Link
ICantNameMe
  • 93
  • 1
  • 1
  • 7
Loading