Question

Write two programs Client and Server

Given two integer matrices A and B, you are requested to compose a program to perform matrix addition (A + B). Both matrices have N rows and M columns; N > 1, M > 1; You need to divide both (A and B) into four equal (or close to equal) size of submatrices (A0,0, A0,1, A1,0, A1,1 and B0,0, B0,1, B1.0, B1.1)andeachsubmatrixhasdimensioncloseto(N/2)x(M/2). YouneedtocreatefourJavathreads each thread performs a subset of addition on one pair of the submatrices. Example, thread 0 performs addition on A0,0 and B0,0, thread 1 performs addition on A0,1 and B0,1, . . . etc. The final result should store in the matrix C of size N by M.

There must be a GUI implemented on the client side. The client is also in charge of reading in the data from file and transmitting the two matrices to the server. The server will receive the two 2D arrays and coordinate creation of four threads to add up the quadrants of the two matrices. The server will then send the results back to the client for the client to display on the GUI s textarea.

The server should wait for a TERMINATE String from the client before closing the connection. That means that the server will likely need to use instanceof in order to distinguish between String and int[][] type data.


  1. 1)  Client – a GUI with text area for user input (file name) and a text area to display the result. After receiving the file name from the user interface, the client opens and reads the file (the format of the file is described below) for the two matrices A and B.
    Send both matrices to the Server, wait for the result from the server, and display the result on the display area with N rows and M columns.

  2. 2)  Server – Starting and waiting for client connection. Receive both matrices A and B from the client, divide both matrices into four submatrices and generate four threads (processes) as described above (you are encouraged to re-use your Lab3 objects) to perform the requested addition.

    After completing the computation, send the result to the client. Then wait for another request from the client. Note: the server should run forever, waiting for clients to request connections.

File Format

  1. 1)  the first line has two numbers, N and M (N rows, M columns), the size of both matrices A and B

  2. 2)  the next N lines each has M elements for one of the rows of A

  3. 3)  the next N lines each has M elements for one of the rows of B

Example:

46 231251

312224
123272
361513
654143
332211
754325
218484
For the above example, the result of the computation on the console should be

885394 644435 877597 579997

Instructions

  •   You must use NxM two-dimension arrays for your implementation

  •   You must divide the two-dimensional array into the form such as: 𝐴 = [𝐴0,0

    andC.

  •   After the computation, the result needs to be stored in the matrix C.

  •   Your program should work on any size matrix.

    Server and Client will be run as separate processes (logically separated on the same machine) though you could connect them across a network if you wanted. When making connection, the client needs to specify where the server is (the server IP address, localhost is one of the choices). There are no prior requirements on how to design your GUI, however you should provide a reasonable format to display the N by M results.


  1. The Client needs to prompt the user for the input file name, open and read the file. Send the two NxM matrices to the server. After the Server receives the matrices, it performs the computation, then sends the results back to the Client. Client then displays the results on the Client’s GUI.

    Note: Both Client and Server may terminate the connection by issuing the TERMINATE command.


0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Write two programs Client and Server
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • JAVA PROGRAM. I need to write a program in java that will perform matrix addition and both matric...

    JAVA PROGRAM. I need to write a program in java that will perform matrix addition and both matrices have N rows and M columns, N>1 and M>1. The two matrices must be divided to four equal size sub-matrices and each sub-matrix has dimensions N/2 X M/2. I need to create four threads and each thread performs a sub-set of addition on one pair of the sub-matrices. I also need an extra thread for networking. The network part of this uses...

  • Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array...

    Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...

  • Assignment One program will be the update server and the other will be the update client....

    Assignment One program will be the update server and the other will be the update client. Here is how the two programs should interact with each other: Server 1. the server starts up and reads the version number in the data.bin file and stores it in memory. 2. The server binds to a port and awaits connections. Client 1. The client starts up and it will first read the version number found within it's own data.bin file. 2. The client...

  • Using network sockets, write a C program called client that receives three command-line arguments in the...

    Using network sockets, write a C program called client that receives three command-line arguments in the form: client host port file and sends a request to a web server. The command-line arguments are hostRepresents the web server to connect to port Represents the port number where a request is sent. Normally an HTTP request is sent over port 80, but this format allows for custom ports file Represents the file requested from the web server Your program should create a...

  • You are to write a Java program using the following instructions to build a bank-ATM server...

    You are to write a Java program using the following instructions to build a bank-ATM server system with sockets. A bank holds accounts that can have deposits, withdrawals, or retrievals of balance. The bank server provides the account for transactions when a client uses and ATM machine. The ATM asks for the type of transaction and the amount (if needed), then creates a socket connection to the bank to send the transaction for processing. The bank performs the transaction on...

  • C++ must use header files and implementation files as separate files. I’ll need a header file,...

    C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...

  • Write a method to multiply two matrices. The header of the method is: public static double[][]...

    Write a method to multiply two matrices. The header of the method is: public static double[][] multiplyMatrix(double[][] a, double[][] b) To multiply matrix a by matrix b, the number of columns in a must be the same as the number of rows in b, and the two matrices must have elements of the same or compatible types. Let c be the result of the multiplication. Assume the column size of matrix a is n. Each element is For example, for...

  • IN UNIX, MODIFY CODE, PROVIDE SCREENSHOTS FOR GOOD RATING: T1. Modify Client.c program to accept two...

    IN UNIX, MODIFY CODE, PROVIDE SCREENSHOTS FOR GOOD RATING: T1. Modify Client.c program to accept two arguments (IP add & port no. of the concurrent Server with thread - conServThread.c). Similarly, modify the Server (conServThread.c) program to accept an argument which is the port number of the server to bind and listen to. Try these two updated programs (server and client) with a port number (e.g., hhmm6) with current time where hh is hours in 24-hour format and mm is...

  • 1. Write two programs that play a trivia game using shared memory. Include examples of your...

    1. Write two programs that play a trivia game using shared memory. Include examples of your program output in a report. In order to synchronize the question-answer-result sequence, you will force processes to sleep. Create separate server and client programs (two .c files) according to the following design requirements .The server is assumed to be executed before the client. . The server creates the shared memory and writes a string to shared memory containing the trivia question and sleeps for...

  • Using the programming language of your choice, write a client application which: Connects to a network...

    Using the programming language of your choice, write a client application which: Connects to a network service, then Asks for version information, then Receives the response, then Disconnects and Prints out the response. Detail: The program will take no input from the user. When your program is executed, it should connect to IP address 64.183.98.170 on port 3800. Upon successful connection, send the string: version\n where \n is an end of line marker. The server will respond with a string...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT