Question 1
Which function is used to create a message queue?
mq_open()
msgget()
semget()
shmget()
Question 2
What is printed if successful?
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdio.h>
int main() {
int id = msgget(IPC_PRIVATE, 0666 | IPC_CREAT);
if (id < 0) printf("Error\n");
else printf("Queue created\n");
return 0;
}
Queue created
Error
Nothing
Compiler error
Question 3
Which of these is NOT an IPC mechanism?
Message queues
Semaphores
Shared memory
Signals
Question 4
Which header file is essential for using socket functions like socket(), bind(), and accept()?
<netdb.h>
<unistd.h>
<sys/socket.h>
<sys/types.h>
Question 5
Which structure is used to define an address for socket communication in IPv4?
struct hostent
struct sockaddr_in
struct in_addr
struct ip_addr
Question 6
What is the role of htons() in socket programming?
Converts port number to host byte order
Converts port number to network byte order
Hashes the port number
Assigns a port number automatically
There are 6 questions to complete.