Sockets

Question 1
Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIX socket API.  
A
listen, accept, bind recv
B
bind, listen, accept, recv
C
bind, accept, listen, recv
D
accept, listen, bind recv
       Computer-Networks       Sockets       GATE 2015 -(Set-2)
Question 1 Explanation: 
Question 2
Which one of the following socket API functions converts an unconnected active TCP socket into a passive socket?
A
connect
B
bind
C
listen
D
accept
       Computer-Networks       Sockets       Gate 2014 Set -02
Question 2 Explanation: 
(a) The connect function is used by a TCP client to establish a connection with a TCP server.
(b) The bind function assigns a local protocol address to a socket. With the Internet protocols, the protocol address is the combination of either a 32-bit IPv4 address or a 128-bit IPv6 address, along with a 16-bit TCP or UDP port number.
(c) The listen function converts an unconnected socket into a passive socket, indicating that the kernel should accept incoming connection requests directed to this socket.
(d) The accept function is called by a TCP server to return the next completed connection from the front of the completed connection queue. If the completed connection queue is empty, the process is put to sleep (assuming the default of a blocking socket).
Question 3
Which of the following system calls results in the sending of SYN packets?
A
socket
B
bind
C
listen
D
connect
       Computer-Networks       Sockets       Gate-2008
Question 3 Explanation: 
When connect( ) is called by client, following three way handshake happens to establish the connection in TCP.
1) The client requests a connection by sending a SYN (synchronize) message to the server.
2) The server acknowledges this request by sending SYN-ACK back to the client.
3) The client responds with an ACK, and the connection is established.
Question 4

A client process P needs to make a TCP connection to a server process S. Consider the following situation: the server process S executes a socket (), a bind () and a listen () system call in that order, following which it is preempted. Subsequently, the client process P executes a socket () system call followed by connect () system call to connect to the server process S. The server process has not executed any accept() system call. Which one of the following events could take place?

A
connect ( ) system call returns successfully
B
connect ( ) system call blocks
C
connect ( ) system call returns an error
D
connect ( ) system call results in a core dump
       Computer-Networks       Sockets       Gate-2008
Question 4 Explanation: 
Connect() System call is not blocking system call but it blocks until connection is established or rejected. If accept() is not executed at server then connection will be rejected and an error statement is returned.
There are 4 questions to complete.
PHP Code Snippets Powered By : XYZScripts.com