Modify, compile, and test the client program in Table 25.13 and the server program in Table 25.12
Question:
Modify, compile, and test the client program in Table 25.13 and the server program in Table 25.12 to do the following: The client program needs to read the request string from a file and store the response string in another file. The name of the file needs to be passed as the argument to the main method of the client program. The server program needs to accept the request string, change all lowercase letters to uppercase letters, and return the result.
Table 25.12
Table 25.13
Transcribed Image Text:
Table 25.12 A simple UDP server program 1 import java.net.*; 2 import java.io."; 4 public class UDPServer final int buffSize = .: I/ Add buffer size. DatagramSocket sock; String request; String response; InetAddress clientAddr; 8 9 10 11 int clientPort; 12 13 UDPServer (DatagramSocket s) 14 15 sock = s; 16 17 18 void getRequest ) 19 { 20 try 21 { byte [] recvBuff = new byte [buffSize]: DatagramPacket recvPacket = new DatagramPacket (recvBuff, buffSize); sock.receive (recvPacket); recvBuff = recvPacket.getData (); request = new String (recvBuff, 0, recvBuff.length); clientAddr = recvPacket.getAddress (); clientPort = recvPacket.getPort (); 28 catch (SocketException ex) 31 32 System.err.println ("SocketException in getRequest"); 33 } 34 catch (IOException ex) 35 36 System.err.println ("IOException in getRequest"); 37 } 38 39 40 void process () 41 { 42 // Add code for processing the request and creating the response. 43 45 void sendResponse) 46 47 try 49 byte [] sendBuff = new byte [buffSize]; sendBuff = response.getBytes (); 51 DatagramPacket sandpaper = new DatagramPacket (sendBuff, sendBuff.length, clntAddr, clientPort); sock.send(sendPacket); } 55 catch (SocketException ex) System.err.println ("SocketException in sendResponse"); 58 59 catch (IOException ex) 60 61 System.err.printin ("IOException in sendResponse"); 62 63 64 65 public static void main (String [] args) throws IOException, SocketException 66 67 final int port =...; // Add server port number. 68 DatagramSocket sock = new DatagramSocket (port); 69 while (true) 70 { 71 UDPServer server = new UDPServer (sock); 72 server.getRequest (); 73 server.process (); 74 server.sendResponse (); 75 76 } // End of main 77 )// End of UDPServer class
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (12 reviews)
This assignment shows how we can add some classes to ...View the full answer
Answered By
Keziah Thiga
I am a self motivated financial professional knowledgeable in; preparation of financial reports, reconciling and managing accounts, maintaining cash flows, budgets, among other financial reports. I possess strong analytical skills with high attention to detail and accuracy. I am able to act quickly and effectively when dealing with challenging situations. I have the ability to form positive relationships with colleagues and I believe that team work is great key to performance. I always deliver quality, detailed, original (0% plagirism), well-researched and critically analyzed papers.
4.90+
1504+ Reviews
2898+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Modify, compile, and test the client program in Table 25.17 and the server program in Table 25.16 to allow the client to provide the pathname of a short file stored on the server host. The server...
-
Modify, compile, and test the client program in Table 25.17 and the server program in Table 25.16 to simulate a local DNS client and server. The server has a short table made of two columns, domain...
-
Assume we want to make the TCP client program in Table 25.2 more generic to be able to send a string and to handle the response received from the server. Show how this can be done. Table 25.2 Echo...
-
From the densities of the lines in the mass spectrum of krypton gas, the following observations were made: Somewhat more than 50% of the atoms were krypton-84. The numbers of krypton-82 and...
-
Terry Lam and Chris Tan have a partnership agreement with the following provisions for sharing profit or loss: 1. A salary allowance of $20,000 to Lam and $30,000 to Tan 2. An interest allowance of...
-
Alice can use only the additive cipher on her computer to send a message to a friend. She thinks that the message is more secure if she encrypts the message two times, each time with a different key....
-
Review the information on YouTube in this section of the chapter and conduct your own research. What evidence is there that beginning with the end in mind was part of YouTubes founders original plan?
-
Wendt Corporation acquired a new depreciable asset for $94,000. The asset has a four-year expected life and a residual value of zero. Required: 1. Prepare a depreciation schedule for all four years...
-
TB MC Qu. 3-53 (Algo) Listed below are year-end account balances... Listed below are year-end account balances ($ in millions) taken from the records of Symphony Stores. Debit Credit Accounts...
-
Major Project - Andrew Best - Best Business Solutions Incorporated (BBSI) Andrew Best was a very inquisitive child growing up. He was a great student in school and always asked a lot of questions....
-
Write a method in Java to convert a 32-bit integer to a string representing an IP address in the form x.y.z.t.
-
Most of the operating systems installed on personal computers come with several client processes, but normally no server processes. Explain the reason.
-
Using Exhibit 1, prove that total revenue at P1 is greater than total revenue at P2.
-
Are the following statements positive or normative? Why? a. Employers should not be required to offer pensions to their employees. b. Employers offering pension benefits will pay lower wages than...
-
The federal minimum wage was increased on July 24, 2007, to $5.85 from $5.15. If 16 hours per day are available for work and leisure, draw the daily budget constraint for a worker who was earning the...
-
Common carriers have a legal duty to protect passengers from criminal attacks. True False
-
The public utilities commission in a state lifts price controls on the sale of natural gas to manufacturing plants and allows utilities to charge market prices (which are 30 percent higher). What...
-
Suppose you have information on which of the 13 randomly selected teenage workers in the fast-food industry worked part-time and which worked fulltime. Variable F i is equal to 1 if the worker is...
-
What is the hidden job market, and how can candidates find jobs in it?
-
Ashlee, Hiroki, Kate, and Albee LLC each own a 25 percent interest in Tally Industries LLC, which generates annual gross receipts of over $10 million. Ashlee, Hiroki, and Kate manage the business,...
-
Use the following brief description of operations as the source for the next database design: All aircraft owned by ROBCOR require periodic maintenance. When maintenance is required, a maintenance...
-
You have just been employed by the ROBCOR Trucking Company to develop a database. To gain a sense of the databases intended functions, you have spent some time talking to ROBCORs employees and youve...
-
Why must a conceptual model be verified? What steps are involved in the verification process?
-
A 1 kg metal block is heated to 200 C and then dropped into a thermally isolated container with 4 kg of water and 100 gr of ice both at a temperature of 0 C. If the specific heat of water is cw=4186...
-
Why are both ER Diagrams and Relational Modeling needed when a database system is developed?
-
Which data model provides a user with the best "program-data independence"? A. Hierarchial Model B. Network Model C. Relational Model D. Entity Relationship Model Why?
Study smarter with the SolutionInn App