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...
-
On February 10, Mrs. Sunderhaus purchased a diamond ring from Perel & Lowenstein for $6,990. She was told by the companys salesperson that the ring was worth its purchase price, and she also received...
-
Suzanne Luken opened a medical practice titled Suzanne Luken M.D., Inc. During March, the first month of operations, the business experienced the following events: Requirement 1.Analyze the effects...
-
Name and describe the four types of markets recognized by economists and discuss the pricing challenges posed by each.
-
Interstate Manufacturing is considering either overhauling an old machine or replacing it with a new machine. Information about the two alternatives follows. Management requires a 10% rate of return...
-
A test of tennis serve accuracy resulted in the following data: Note: Higher scores indicate better performance. X 15 12 12 10 8 7 5 4 4 1. What is the percentile rank of a person who scored (a) 7;...
-
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.
-
Determine the impedance ZL for maximum average power transfer and the value of the maximum average power absorbed by the load in the network shown infigure. 6/0 V jin 310 10 IZ 1a
-
7. Pili are also called a. microvilli. b. fimbriae. c. cilia. d. flagella. 8. The structures that can move fluid, mucus, or cells over the surface of a cell are a. microvilli. b. fimbriae. c. cilia....
-
Newton's Law of Cooling states that the rate of change of the temperature of an object, T, is proportional to the difference of T and the temperature of its surrounding environment. A pot of chili...
-
Andler Inc. estimates that an allowance of $4,000 is required on its accounts receivable balance of $80,000 as of December 31 of Year 1. Required a. What is the net amount expected to be collected on...
-
b) Each individual has an expected utility function that looks like the following: EU pin()+(1) where p is the probability of an accident, P is an individual's net income in case of an accident. and...
-
Racing on a flat track, a car going at a tangential velocity of 32 m/s rounds a curve 56 m in radius. What is the car's centripetal acceleration in (m/s/s)? A runner moving with a tangential velocity...
-
What is a request for proposal (RFP)? How are responses to an RFP evaluated?
-
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?
-
Industry and Competition Analysis Learn as much as possible about the industry which the company aspires to enter. Be explicit on how you define your client's market, who the customers are, and who...
-
Now that you updated the written communication for the "New Procedures," in 200-250 words, describe the best channels to use for distributing the updated message to promote its reception and maximize...
-
Complete the provided table by finding the appropriate information and data points for each identified category using course and external resources. Then explain the insight that each selected...
Study smarter with the SolutionInn App