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...
-
Golden Eagle Company prepares monthly financial statements for its bank. The November 30 adjusted trial balance includes the following account information: The following information is known for the...
-
Lomax Oil Company drilled an exploratory well on a lease located in a remote area. The well found reserves, but not enough to justify building a necessary pipeline. The company does not plan to drill...
-
Toys R Us sells a variety of childrens toys, games, books, and accessories. Assume that a local store has the following amounts for the month of March 2015. Required: 1. Prepare a multiple-step...
-
Find the equation of the line in slope-intercept form. Describe or show your work. No work, No Credit. 800- -400- a 5000 10000 15000 20000 25008
-
18. Add the Office field to the Filters area of the Pivot Table. Filter the table so that only organizations with private offices are visible.
-
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.
-
Factor the expression completely. 2 - 9z+20
-
When the financial statements contain a material departure from generally accepted accounting principles, the auditor should issue either a. An unqualified or qualified opinion. b. A qualified...
-
A cone clutch of semi-cone angle \(15^{\circ}\) is used to transmit \(30 \mathrm{~kW}\) at \(800 \mathrm{rpm}\). The mean frictional surface radius is \(150 \mathrm{~mm}\) and normal intensity of...
-
Audit risk and materiality should be considered when planning and performing an audit of financial statements in accordance with generally accepted auditing standards. Audit risk and materiality...
-
Explain the difference between accounting and auditing.
-
The first general standard of generally accepted auditing standards states that a. An independence in mental attitude is to be maintained. b. Due professional care is to be exercised. The audit is to...
-
Evaluate the indefinite integral. (arctan x)? dx x + 1
-
Suppose that a company has 10.000 outstanding shares in the beginning of the year. On April 1st, the company increases its shares by 6.000. On July 1st, the company increases its shares again, but...
-
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?
-
On 1 January 20.1 SA Traders purchased office furniture for R80 000. The financial year-end of SA Traders is 31 December.Calculate the accumulated depreciation for 20.3 by using the reducing-balance...
-
Customs agents are on the lookout for situations where the value of the transaction (invoice value) may not represent the true value of goods being imported. Identify the 3 situations most likely to...
-
Iverson, Inc. has $1,294,000 of sales revenue, $692,000 of variable costs, and $692,000 of fixed costs in 2023. Assuming the contribution margin percentage stays the same in 2024, what will the break...
Study smarter with the SolutionInn App