CS390006 Assignment 2 Solved

30.00 $

Category:

Description

5/5 - (1 vote)

Using TCP Sockets

Problem 2(a):

In this problem, you will write a client-server system using UDP sockets to convert a given DNS name (for ex., www.google.com) into its IP address(es). The client program will prompt the user for a DNS name, read it as a string and send it to the server using the UDP socket The server will convert the name to its equivalent IP addresses and returns them back to the client. If no IP address can be found, a special address (0.0.0.0) is returned. The client will then print all the addresses returned (or a suitable message if 0.0.0.0 is returned), and exit. You can assume the server will handle the different requests iteratively one after the other.

The gethostbyname( ) function takes as parameter a DNS name and returns IP address(es) corresponding to it in a special data structure. You can read the description of the function from the man page and the material given.

Problem 2(b)

Suppose that in the DNS system above, some clients will connect over TCP and some will connect over UDP sockets. Thus, the server will need to open both a TCP socket and a UDP socket, and accept DNS name resolution request from any one of them whenever they come. Use the select() call to modify your UDP server of Problem 2(a) above to do this. Also, in this case, the server is a concurrent server, so it will handle each request by spawning a new process using the fork() call.

Also write a TCP client whose behaviour is the same as the UDP client of Problem 1(a), just that it will use a TCP socket instead of a UDP socket.

  • Assignment-2-pohbul.zip