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...
-
The capital budgeting process is dependent on the anticipated cash flows generated by a proposed capital project. Research the importance of the price to cash flow ratio and the free cash flow in...
-
Do our stakeholders think we're doing a good job? Do we have a good relationship with those stakeholders?
-
Many companies use budgets for three purposes. First, they use them to plan how to deploy resources to best serve customers. Second, they use them to establish challenging goals, or stretch targets,...
-
Fogerty Company makes two products-titanium Hubs and Sprockets. Data regarding the two products follow: Direct Labor- Hours per Annual Unit Production Hubs 0.60 16,000 units Sprockets 0.20 44,000...
-
Round the following numbers to two decimal places: a. 26.412 ____________ b. 62.745 ____________ c. 36.846 ____________
-
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 following cash data were adapted from the annual report of Apple Computer Inc. for the period ended September 25, 2004. The cash balance as of September 26, 2003, was $3,396 (in millions). In...
-
Consider the following double loop and identify the dependence. Verify the dependence(s) by applying GCD test and Bounds test. Use the direction vector of (1, -1) corresponding to T on (5M) S. L1: do...
-
After discovering a vulnerability in the passwd utility, the Linux developers have decided that it is too dangerous to continue to run the utility as root (through setuid). Unfortunately, there's no...
-
Your supervisor comes to you and says, that as a company, you're facing multiple communication challenges. Since transitioning to a remote workforce, communication has been extremely poor....
-
You are developing an application that will be running on several hundred Amazon EC2 instances. The application on each instance will be required to reach out through a file system protocol...
-
What is the danger of mixing elements ("hybrid strategy") from both agile and lean SC strategies?
-
Construct the analogs to Equation 10.12 for one-dimensional and two-dimensional scattering. eikr v (r.0) A {eik + (0)hr}. for large r. (10.12)
-
(a) As Section 17.3 discusses, high-frequency sound waves exhibit less diffraction than low-frequency sound waves do. However, even high-frequency sound waves exhibit much more diffraction under...
-
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?
-
Required : a- outline the statement of comperhensive income for the year ended 30 november 2021 b- outline the statment of financial position as at 30 November The Trial Balance of Alim Enterprise at...
-
International business and environment The MIR requires teams to gather current, or the most recently available, data on the markets people, economy, government, and technological status from online...
-
Consider the following stream of cash flows. The interest rate is 10%. 0 1 2 3 4 5 6 7 100 100 100 200 0 300 300 300 a) What is the value at time 0 of the cash flow stream? b) What is the value of...
Study smarter with the SolutionInn App