Client and server programs for interaction between server and client processes using Unix Domain sockets

  • Post author:
  • Post category:OS
  • Post comments:0 Comments

client1.c: #include #include #include #include #include int main(void) { struct sockaddr_un address; int socket_fd, nbytes; char buffer[256]; socket_fd = socket(PF_UNIX, SOCK_STREAM, 0); if(socket_fd < 0) { printf("socket() failedn"); return 1;…

Continue ReadingClient and server programs for interaction between server and client processes using Unix Domain sockets

C program to create a message queue with read and write permissions to write 3 messages to it with different priority numbers

msgget():The msgget function can be used to create the message queue. msgrcv():The msgrcv function can be used to receive the messages. msgsnd():The msgsnd function can be used to send the…

Continue ReadingC program to create a message queue with read and write permissions to write 3 messages to it with different priority numbers

C programs that illustrate communication between two unrelated processes using named pipe

#include #include #include #include int main() { int pfds[2]; char buf[30]; if(pipe(pfds)==-1) { perror("pipe"); exit(1); } printf("writing to file descriptor #%dn", pfds[1]); write(pfds[1],"test",5); printf("reading from file descriptor #%dn ", pfds[0]);…

Continue ReadingC programs that illustrate communication between two unrelated processes using named pipe

Program that illustrates how to execute two commands concurrently with a command pipe

#include #include #include int main() { int pfds[2]; char buf[30]; if(pipe(pfds)==-1) { perror("pipe failed"); exit(1); } if(!fork()) { close(1); dup(pfds[1]; system (“ls –l”); } else { printf("parent reading from pipe…

Continue ReadingProgram that illustrates how to execute two commands concurrently with a command pipe

C program to create a child process and allow the parent to display “parent” and the child to display “child” on the screen

#include #include /* contains prototype for wait */ int main(void) { int pid; int status; printf("Hello World!n"); pid = fork( ); if(pid == -1) /* check for error in fork…

Continue ReadingC program to create a child process and allow the parent to display “parent” and the child to display “child” on the screen