UNIVERSITY EXAMINATIONS: 2011/2012
YEAR III EXAMINATION FOR THE BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY
BIT 3105 NETWORK PROGRAMMING
DATE: APRIL 2012 TIME: 2 HOURS
INSTRUCTIONS: Answer Question One and Any other Two Questions
QUESTION ONE
a)Define the following terms as used in network programming:
i. Descriptor [1 Mark]
ii. Protocol family [1 Mark]
iii. aton() [1 Mark]
iv. Zombie state [1 Mark]
v. Thread [1 Mark]
b) What makes a Distributed Operating System suitable for Distributed applications? [2 Marks]
c) “Working with existing I/O services” and “Operating System Independence” are among the
characteristics of network API. Briefly discuss them. [4 Marks]
d) List the two (2) special needs that a socket needs. [2 Marks]
e) Using a well labeled diagram, illustrate the communication between a client and server from
the time a socket is created to when the connection is terminated. [7 Marks]
f) Briefly discuss the basic operation of a concurrent server and its benefits. [5 Marks]
g) Why does an association have five (5) entries instead of six (6)? [2 Marks]
h)Once a TCP connection has been terminated there is a possibility of some unfinished business.
How does TCP take care of these businesses? [3 Marks]
QUESTION TWO
a) Three (3) things happen when a server accepts a connection request from a client. List and
explain them. [6 Marks]
b) There are two main address domains/protocol families: Internet domain and UNIX domain
protocol families. What is the main difference between them? [2 Marks]
c) Differentiate between the following concurrent server designs:
i. One child process per client and a thread per connection [2 Marks]
ii. Preforking multiple processes and static worker pool. [2 Marks]
d) List and briefly discuss the factors that need to be considered in choosing the best server
design. [8 Marks]
QUESTION THREE
a) List and discuss the two (2) types of TCP segments. [4 Marks]
b) Explain what “Byte stream” and “Full duplex” mean in TCP connections. [4 Marks]
c) What is the function of the following fields found in an IP datagram?
i. Time-to-Live (TTL) [2 Marks]
ii. Protocol [2 Marks]
d) What is the role of “host byte order” and “network byte order” in the exchange of data
between a client and server? [4 Marks]
e) “System Programming Interface” and “Data Interface” are some of the interfaces of a
middleware. Discuss these interfaces. [4 Marks]
QUESTION FOUR
a)Explain how “Reverse Address Resolution Protocol” operates. [2 Marks]
b) What do you understand by the term Automatic port number assignment when used in network
programming? [2 Marks]
c) Between TCP and UDP which protocol is better? Explain. [3 Marks]
d) Explain three (3) ways in which a process can terminate normally after you have called fork()
system call. [3 Marks]
e) Study the lines of code presented below and answer the questions that follow:
1. sock=socket(AF_INET, SOCK_DGRAM, 0);
2. if (sock < 0)
error(“Opening socket”);
3. length = sizeof(server);
4. bzero(&server,length);
5. server.sin_family=AF_INET;
6. server.sin_addr.s_addr=INADDR_ANY;
7. server.sin_port=htons(atoi(argv[1]));
8. if (bind(sock,(struct sockaddr *)&server,length)<0)
error(“binding”);
9. fromlen = sizeof(struct sockaddr_in);
i. List and explain the protocol family and service type of the socket created by line 1.
[4 Marks]
ii. What is the importance of line 6? [3 Marks]
iii. Explain the function of line 7. [3 Marks]
QUESTION FIVE
a)Differentiate between:
i. A process and a thread. [2 Marks]
ii. A concurrent server and an iterative server [2 Marks]
iii. Asymmetric and Symmetric Data Representations [2 Marks]
b) Of the two, process or thread, which one is better in developing a concurrent server? Explain.
[3 Marks]
c) Designing distributed programs can take two (2) approaches. List and describe them. [4 Marks]
d) Study the lines of code presented below and answer the questions that follow:
1. serv_addr.sin_addr.s_addr = INADDR_ANY;
2. serv_addr.sin_port = htons(portno);
3. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
error(“ERROR on binding”);
4. listen(sockfd,5);
5. clilen = sizeof(cli_addr);
6. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
7. if (newsockfd < 0)
error(“ERROR on accept”);
8. bzero(buffer,256);
9. n = read(newsockfd,buffer,255);
10. if (n < 0) error(“ERROR reading from socket”);
11. printf(“Here is the message: %s\n”,buffer);
12. n = write(newsockfd,”I got your message”,18);
13. if (n < 0) error(“ERROR writing to socket”);
14. close(newsockfd);
15. close(sockfd);
i. What is the effect of line 3? [2 Marks]
ii. Is this a sequential or concurrent server? Explain. [2 Marks]
iii. Explain what line 6 does. [2 Marks]
iv. Is this a UDP or TCP connection? Why? [1 Mark]