Network Programming: Project 1.

Introduction

In this project you need to create a program that computes perfect numbers. Perfect number is an integer number that equals to the sum of all its divisors except itself. For example, 6 is a perfect number because its divisors are 1, 2, and 3 (1+2+3=6). The total goal of the program is to create a program that computes perfect numbers in parallel in several computers. This project will contain three different programs, which are supposed to work together:
  • manager
  • client
  • reporter

    Manager

    This is the central program of the project. The goal of the program is to maintain information about the job done, give assignments to clients, and provide information to the reporter. This manager program is to be started first and become a server. It should accept connection from clients and give them assignments in the form: "Find all perfect numbers in the range from N to M". It also should accept data from the clients when they report that a perfect number is found, or they have to quit for some reason. The manager program is also supposed to accept requests from the reporter program(s) and give back a detailed report like "N perfect numbers found. They are: 6, ... Currently M clients are computing perfect numbers ...".

    Client

    The client's job is to connect to the manager and receive the range for searching in. Once the range received client is to find all perfect numbers inside the range. Once a perfect number found, the client has to send the number to the server and keep searching for the next one. When the whole range is searched the client can either stop or ask for another range. Client takes the following argument from the command line:
    1. IP address or host name of the server computer (that is, the computer where manager is running)
    2. port number to connect to (the number of the port the manager is listening on)
    3. what to do when the range is searched (exit or ask for more)
    Clients have to stay connected until they decided to quit. If a client decided to stop it should send an end signal to the manager to specify that it stops. Please notice that user may kill a client. In this case client is not able to send the end signal to the server and the only way for the server to understand that client is dead is to monitor the connection. If the connection is closed manager has to release the socket and may reuse it.

    Reporter

    This is probably the easiest part of the project. The reporter's job is to send a request to the manager and get all possible information from it, and then print all the information. The information should include:
  • total amount of the perfect numbers found
  • total amount of the numbers tested
  • perfect numbers found
  • number of the currently working clients, their IPs, host names, and port numbers. The reporter doesn't have to stay connected to the server. Once all needed information received and printed it should close the connection and quit.

    Additions

    You should design and clearly define protocol your programs will be using. What kind of messages they send, format of the messages and possible values and meaning of their fields. All code should be clearly commented. Print a lot of debugging messages included inside the #ifdef ... #endif construction. Do not forget to create a make file.