Write a program to make the UDP server program in Table 25.1 more generic: to receive a
Question:
Write a program to make the UDP server program in Table 25.1 more generic: to receive a request, to process the request, and to send back the response.
Table 25.1
Transcribed Image Text:
Table 25.1 Echo server program using UDP 1 / UDP echo server program 2 #include "headerFiles.h" 3 int main (void) { II Declare and define variables int s; I/ Socket descriptor (reference) // Length of string to be echoed I/ Data buffer int len; 8 char buffer [256]; struct sockaddr_in servAddr; // Server (local) socket address // Client (remote) socket address 10 struct sockaddr_in clntAddr; 11 int clntAddrLen; I/ Length of client socket address I/ Build local (server) socket address memset (&servAddr, 0, sizeof (servAddr)); 12 II Allocate memory 13 // Family field I/ Default port number 14 servAddr.sin_family = AF_INET; 15 servAddr.sin_port = htons (SERVER_PORT) servAddr.sin_addr.s_addr=htonl(INADDR_ANY); I/ Default IP address I/ Create socket if (s = socket (PF_INET, SOCK_DGRAM, 0) < 0); 16 17 18 19 20 perror ("Error: socket failed!"); 21 exit (1); 22 23 I/ Bind socket to local address and port 24 if (bind (s, (struct sockaddr*) &servAddr, sizeof (servAddr) < 0); 25 26 perror ("Error: bind failed!"); 27 exit (1); 28 29 for (; ;) I/ Run forever 30 { I/ Receive String 31 32 len = recvfrom (s, buffer, sizeof (buffer), 0, 33 (struct sockaddr*)&clntAddr, &clntAddrLen); 34 I/ Send String 35 sendto (s, buffer, len, 0, (struct sockaddr*)&clntAddr, sizeof(clntAddr); }// End of for loop 37 } // End of echo server program 36 4799
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 70% (10 reviews)
This is the general UDP server program in the C language in which the server receives an array of ...View the full answer
Answered By
Mamba Dedan
I am a computer scientist specializing in database management, OS, networking, and software development. I have a knack for database work, Operating systems, networking, and programming, I can give you the best solution on this without any hesitation. I have a knack in software development with key skills in UML diagrams, storyboarding, code development, software testing and implementation on several platforms.
4.90+
97+ Reviews
194+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Write a program to make the UDP client program in Table 25.2 more generic to be able to send any request created by the client program. Table 25.2 Echo client program using UDP I/ UDP echo client...
-
Write a program to make the TCP server program in Table 25.3 more generic: to receive a request, to process the request, and to send back the response. Table 25.3 Echo server program using the...
-
Write a program to make the TCP client program in Table 25.4 more generic to be able to send any request created by the program. Table 25.4 Echo client program using TCP 1 / TCP echo client program 2...
-
Write Python code that prompts the user to enter his or her age and assigns the users input to an integer variable named age.
-
Accentrics Limited has the following information available regarding its share capital at December 31, 2016: Preferred shares, $3.50 cumulative, 20,000 shares issued........................$1,000,000...
-
1. Find the intensity of a light source that produces an illumination of 5.50 ft-candles at 9.85 ft from the source. 2. Find the intensity of a light source that produces an illumination of 2.39 lux...
-
Are we able to take creative ideas and turn them into useful products or processes?
-
Ingersoll Rand operates as a manufacturer in four segments: Air Conditioning Systems and Services, Climate Control Technologies, Industrial Technologies, and Security Technologies. They installed an...
-
Problem 6-2A Calculate ending inventory, cost of goods sold, sales revenue, and gross profit for four inventory methods (L06-3, 6-4,6-5) (The following information applies to the questions displayed...
-
1. Which process should VBB choose to produce?? 2. How much would VBP be willing to pay for the testing that is currently offered, for each batch?? 3. Would we be considered a perfect test, at twice...
-
In Figure 25.10 in the text, how does the server know that a client has requested a service? Figure 25.10 Sockets used in TCP communication Server O Connection establishment Client 1 Data transfer...
-
Assume we add a new protocol to the application layer. What changes do we need to make to other layers?
-
5. At the start of this chapter, Graham complains because there are "no girls" on his trip. Take that complaint as a statement of a larger problem- namely, that trips are randomly composed of clients...
-
PROVIDE A CASE BRIEF FOR THE FOLLOWING CASE PROVIDED BELOW: PEOPLE v. REKTE Court of Appeal, Fourth District, Division 2, California. The PEOPLE, Plaintiff and Respondent, v. Viktors Andris REKTE,...
-
The time between release from prison and another crime charge for a certain group of men is 36 months with a standard deviation of 9 months. What percentage of men get charged with a second crime...
-
capacitance simulation: https://phet.colorado.edu/sims/html/capacitor-lab-basics/latest/capacitor-lab-basics_en.html w Lab 4 (1).docx Homework Help - Q&A from Or x + C...
-
Mel Jackson, a resident of Tennessee, has been a driver for Blues Delivery Company for the past 7 years. For this purpose, he leases a truck from Blue, and his compensation is based on a percentage...
-
On Halloween night, a small boy decided to dress up as a bank robber. He went to house where the lights were on, indicating that the owner was receiving trick-or-treaters. When the homeowner, a...
-
Find an upper bound on the energy of the first excited state of the hydrogen atom. A trial function with = 1 will automatically be orthogonal to the ground state (see footnote 6); for the radial...
-
1. Use these cost, revenue, and probability estimates along with the decision tree to identify the best decision strategy for Trendy's Pies. 2. Suppose that Trendy is concerned about her probability...
-
What Oracle function should you use to calculate the number of days between your birthday and the current date?
-
What string function should you use to list the first three characters of a companys EMP_LNAME values? Give an example, using a table named EMPLOYEE.
-
What two things must a SQL programmer understand before beginning to craft a SELECT query?
-
Each week you must submit an annotated bibliography. Entries of current events relating to the economic concepts and the impact on the company or the industry of your company. You must use acceptable...
-
Fluffy Toys Ltd produces stuffed toys and provided you with the following information for the month ended August 2020 Opening WIP Units 5,393 units Units Started and Completed 24,731 units Closing...
-
Part A Equipment 1,035,328 is incorrect Installation 44,672 is incorrect Anything boxed in red is incorrect sents 043/1 Question 9 View Policies Show Attempt History Current Attempt in Progress...
Study smarter with the SolutionInn App