WorksheetsCN Quiz
Total questions: 20
Worksheet time: 14mins
What is the purpose of a socket in networking?
To connect two computers physically
To enable communication between processes over a network
To provide power to a device
To store data temporarily
Which type of socket provides reliable, connection-oriented communication?
Stream socket (SOCK_STREAM)
Datagram socket (SOCK_DGRAM)
BOTH Stream socket
and Datagram socket
Broadcast socket
Which function is used to create a socket in C?
socket()
bind()
listen()
accept()
What does the bind() function do?
Associates a socket with an IP address and port number
Establishes a connection to a remote server
Puts a socket in passive mode
Reads data from a socket
What does the socket() function in C return?
A file descriptor (socket descriptor)
int
An IP address and a A port number
Bool
Which function extracts the first connection request from the queue of pending connections?
connect()
accept()
send()
recv()
What is the primary difference between TCP and UDP sockets?
TCP sockets are connectionless, while UDP sockets are reliable
TCP sockets provide reliable, ordered communication, while UDP sockets are connectionless and unreliable.
UDP sockets are used for web browsing, while TCP sockets are used for video streaming.
TCP sockets use port numbers, while UDP sockets use IP addresses.
What is the purpose of the connect() function in socket programming?
To create a socket
To bind a socket to an address
To establish a connection to a remote server
To listen for incoming connections
Which one of the following socket API functions converts an unconnected active TCP socket into a passive socket?
Connect
Bind
Listen
Accept
Which of the following transport layer protocol is used to support electronic mail ?
SMTP
IP
TCP
UDP
Identify the correct order in which a server process must invoke the function calls accept,bind,listen and recv according to UNIX socket API
listen,accept,bind,recv
Bind,listen,accept,recv
Bind,accept,listen,recv
accept,listen,bind,recv
Consider socket API on a Linux Machine that supports connected UDP sockets. A connected UDP socket is a UDP socket on which Connect function has already been called . Which of the following statement is/are CORRECT ?
I) A connected UDP socket can be used to communicate with multiple peers Simultaneously .
II) A process can successfully call connect function again for an already connected UDP socket.
I only
II only
Both I and II
Neither I nor II
For the purpose of providing Digital Certificate, ____ is used for establishing an encrypted link between a web server and a browser
Standard service layer
Secure socket layer
Secure service line
Secure service layer
Socket address is:
IPv4 address translated to IPv6 address
Combination of IP address and port address
Combination of MAC address and domain address
Application layer address
Consider the following statements about socket API functions.
I. Bind() converts an unconnected active TCP socket into a passive socket.
II. Listen() waits for incoming connections.
III. Accept() is used to associate a socket with a port on the local machine.
Which of the above statements are incorrect?
I
I and II
II and III
I and III
What is the return type of the socket() function in C?
int
void
Bool
Structure
Which address family is typically used for Internet addresses (IPv4 protocols)?
PF_INET
PF_UNIX
PF_LOCAL
AF_INET
Which parameter specifies the address of the destination in the sendto() function?
sockid
msg
foreignAddr
addrlen
Match the following
I – C, II – A, III - B
I – A, II – C, III - B
I – A, II – B, III - C
Imagine a user sitting at an Ethernet-connected PC. He has a browser open. He types "www.google.com" in the address bar and hits enter.
Now tell me what the first packet to appear on the Ethernet is.
