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...
-
Howell (1992, p. 153) reports on a study by Latané and Dabbs (1975) in which a researcher entered an elevator and dropped a handful of pencils, with the appearance that it was an...
-
The doubling time of any quantity \(n\) is related to the continuous growth rate \(R_{\text {cont }}\) by the relation \(2=\exp n R_{\text {cont }}\). Derive an expression for \(n\) in terms of the...
-
Assume that you are a CPA and a tax specialist. Your clients include Ale and Grains, Inc., an S corporation, and Gustav and Heidi Lager, a married couple who are shareholders and the operators of Ale...
-
Percentage of total sales Sales Variable expenses Contribution margin Fixed expenses Net operating income Product White 48% Fragrant 20% Loonzain 32% $331,200 100% $ 138,000 99,360 30% 110,400 100%...
-
An analysis of transactions for Foley & Co. was presented in E18. Assume that August is the companys first month of business. In E18, An analysis of the transactions made by Foley & Co., a certified...
-
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.
-
The Johnson Cycle Company buys tires to bicycle tires to use in the process of building their bicycles. Johnson cycle wants to find a low-cost supplier for the tires. The criteria for selection will...
-
The year-end balance reported in the raw materials account was $53,000. $26,000 of the raw materials consumed was considered as indirect materials and entered into manufacturing overhead. Amicable...
-
1. Using the Transformer Law, calculate the output current from a transformer with an output voltage of 1,200 V and a supplied voltage of 16 and supplied amperes of 4.
-
Products is a cranberry cooperative that operates two divisions, a harvesting division and a processing division. Currently, all of harvesting's output is converted into cranberry juice by the...
-
local health care facility has fixed costs per month of $187 400. They also have patient costs of $4.15 per day per patient for linen and cleaning, medication costs are $23.32 per patient per day and...
-
An employer contributes $20,000 (made up of Superannuation Guarantee and salary sacrifice contributions) to a complying superannuation fund for the year ended 30 June 2014 on behalf of employee John,...
-
Does HRT influence the chance of a woman getting cardiovascular disease? Refer to a study on hormone replacement therapy. Until 2002, hormone replacement therapy (HRT), taking hormones to replace...
-
What are the two components of a company's income tax provision? What does each component represent about a company's income tax provision?
-
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?
-
Subtract and simplify: 5x-6x+2-(-2-x+2x)
-
In order to value a company, you would need to forecast its future (a key word here) free cash flows. How would you approach this task? Using downloaded real data, try to make the forecast and see,...
-
share five (5) pieces of advice you would give the class about personal financial planning. Explain each. You might go back and look at the introductions in the first discussion for a general,...
Study smarter with the SolutionInn App