Posts

Part A-4

Image
  // C client code to send string to reverse //p4client.c #include <arpa/inet.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <unistd.h>     #define PORT 8090     // Driver code int main() {     struct sockaddr_in address;     int sock = 0, valread;     struct sockaddr_in serv_addr;     char str[100];         printf("\nInput the string:");     scanf("%[^\n]s", str);         char buffer[1024] = { 0 };         // Creating socket file descriptor     if ((sock = socket(AF_INET,                   ...

Part A-1

  #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h>   void sighup(); void sigint(); void sigquit();   int   main() {    int pid;      if ((pid = fork()) < 0)    {       perror("fork");       exit(1);    }      if (pid == 0)    {       signal(SIGHUP, sighup);       signal(SIGINT, sigint);       signal(SIGQUIT, sigquit);       for (;;)           ;    }      else    {      printf("\nPARENT: sending SIGHUP\n\n");      kill(pid, SIGHUP);        sleep(3);  ...

Part A-3

Image
  Run the two programs simultaneously on two terminals. Pgm-3 #include <stdio.h> #include <string.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h>     int main() {     int fd;         // FIFO file path     char * myfifo = "/tmp/myfifo";         // Creating the named file(FIFO)     // mkfifo(<pathname>, <permission>)     mkfifo(myfifo, 0666);         char arr1[80], arr2[80];     while (1)     {         // Open FIFO for write only         fd = open(myfifo, O_WRONLY);         ...