BIT3105  NETWORK PROGRAMMING.

UNIVERSITY EXAMINATIONS: 2017/2018
EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY
BIT3105 NETWORK PROGRAMMING
BCT 2203: CLIENT/SERVER COMPUTING
FULL TIME/PART TIME/DISTANCE LEARNING
DATE: APRIL 2018 TIME: 2 HOURS
INSTRUCTIONS
Answer Question ONE (Compulsory) and Any Other Two Questions.

Question One (Compulsory – Total 30 Marks)
(a) Explain briefly the difference among bind(), connect() and accept() network APIs with regard to
the parameters taken by these APIs. [6 Marks]
(b) An operating system is defined as a manager of computer resources. List and briefly discuss any
three (3) of these resources. [6 Marks]
(c) Differentiate between these classes of Client/Server systems: client-based and co-operative
processing. [4 Marks]
(d) IP has two primary functions: packet delivery and translation of packets from different data link
layer implementations. List and briefly explain any two (2) services that IP uses to perform these
functions. [4 Marks]
(e) What is the difference between a middleware and a Distributed Operating System? [2 Marks]
(f) With the use of appropriate examples, explain connection-less and connection-oriented services.
[4 Marks]
(g) A sequential server handles one client at time. Discuss, briefly, why the server does not die after
attending to a client. [4 Marks]
Question Two (Total 20 Marks)
(a) (i) Using appropriate examples, explain the difference between a process and a thread. [2 Marks]
(ii) Of the two, process or thread, which one is better in developing a concurrent server? Explain.
[3 Marks]
(b) Briefly explain how the data interface is used by various applications to share information.
[2 Marks]
(c) From a client/server perspective, subnetting is important when it comes to the placement of servers.
Explain what you understand by this statement. [3 Marks]
(d) You have been approached by a distributed application developer with a request for subnetting the
network. The intention is to come up with mirrored servers in order to improve responses. You use a
class C IP address 192.168.1.0 for your network. The request from the developer is for 5 subnets.
(i) What will the new subnet mask be for the subnets? [2 Marks]
(ii) Give the IP address ranges for the 1st three (3) subnets. Show your workings. [3 Marks]
(iii) Give the network addresses (NetID) for these subnets. [2 Marks]
(iv) The developer states that the mirror servers will use the last usable IP addresses of the 3rd, 4th and 5th
subnets. Give these IP addresses. [3 Marks]
Question Three (Total 20 Marks)
(a) What is the difference between “Internet Header Length” and “Total Length” fields in an IP
datagram? [2 Marks]
(b) Briefly explain the fact that ARP and RARP are broadcast protocols. [2 Marks]
(c) Differentiate between the following:
(i) Location and Relocation transparency [2 Marks]
(ii) Migration and Replication transparency [2 Marks]
(iii) fork() and spawn() [2 Marks]
(d) (i) Briefly discuss the heterogeneous environments that RPCs have to contend with. [6 Marks]
(ii) What differentiates remote procedure call from remote method invocation? [4 Marks]
Question Four (20 Marks)
(a) The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT,
UPDATE, DELETE and DROP. These commands can be classified into the following groups based
on their nature: Data Definition Language; Data Manipulation Language and Data Control
Language. Briefly explain each of these classifications. [6 Marks]
(b) For the following relation schema:
employee(employee-name, street, city)
works(employee-name, company-name, salary)
company(company-name, city)
manages(employee-name, manager-name)
Give an expression in SQL for each of the following queries:
(i) Find the names, street address, and cities of residence for all employees who work for ‘First Bank
Corporation’ and earn more than KES10,000. [2 Marks]
(ii) Find the names of all employees in the database who live in the same cities as the companies for
which they work. [2 Marks]
(iii) Find the names of all employees in the database who live in the same cities and on the same streets
as do their managers. [3 Marks]
(iv) Find the names of all employees in the database who do not work for ‘First Bank Corporation’.
Assume that all people work for exactly one company. [3 Marks]
(v) Find the names of all employees in the database who earn more than every employee of ‘Small Bank
Corporation’. Assume that all people work for at most one company. [2 Marks]
(c) What is the difference between 1-Tier and Multi-user 1-Tier client/server architectures? [2 Marks]
Question Five (20 Marks)
Study the code provided below and answer the questions that follow.
1) #include <stdio.h>
2) #include <stdlib.h>
3) #include <sys/socket.h>
4) #include <string.h>
5) #include <sys/types.h>
6) #include <netinet/in.h>
7) #include <netdb.h>
8)
9) int main(int argc, char** argv)
10) {
11) struct addrinfo hints, *server;
12) memset(&hints, 0, sizeof hints);
13) hints.ai_family = AF_INET;
14) hints.ai_socktype = SOCK_STREAM;
15) hints.ai_flags = AI_PASSIVE || SOCK_NONBLOCK;
16) getaddrinfo(NULL, “80”, &hints, &server);
17)
18) int sockfd = socket(server->ai_family,server->ai_socktype, server->ai_protocol);
19) bind(sockfd, server->ai_addr, server->ai_addrlen);
Page 4 of 4
20) listen(sockfd, 10);
21) struct sockaddr_storage client_addr;
22) socklen_t addr_size = sizeof client_addr;
23) char headers[] = “HTTP/1.0 200 OK\r\n Server: CPi\r\nContent-type: text/html\r\n\r\n”;
24) char buffer[2048];
25) char html[] = “<html><head><title>Temperature</title>
</head><body>{\”humidity\”:81%,\”airtemperature\”:23.5C}</p></body></html>\r\n”;
26) char data[2048] = {0};
27) snprintf(data, sizeof data, “%s %s”, headers, html);
28) for (;;) {
29) int client_fd = accept(sockfd, (struct sockaddr *) &client_addr, &addr_size);
30) if (client_fd > 0) {
31) int n = read(client_fd, buffer, 2048);
32) printf(“%s”, buffer);
33) fflush(stdout);
34) n = write(client_fd, data, strlen(data));
35) close(client_fd);
36) }
37) }
38) return (EXIT_SUCCESS);
39) }
(a) Explain briefly the functions of lines 13, 14 and 15. [6 Marks]
(b) What are the roles of lines 21 and 22? [2 Marks]
(c) Explain what happens when lines 28 to 37 are executed. [6 Marks]
(d) This server is referred to as a non-blocking server. Explain what you understand by this.
[2 Marks]
(e) Which transport layer protocol does this server use? Explain. [2 Marks]
(f) Which type of client is this server expected to respond to? [2 Marks]

(Visited 96 times, 1 visits today)
Share this:

Written by