Write a program to make the UDP client program in Table 25.2 more generic to be able
Question:
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.
Transcribed Image Text:
Table 25.2 Echo client program using UDP I/ UDP echo client program #include "headerFiles.h" int main (int arge, char* argv[ ]) // Three arguments to be checked later // Declare and define variables int s; I/ Socket descriptor 6. // Length of string to be echoed // Server name int len; char* servName; I/ Server port // String to be echoed // Data buffer // Server socket address int servPort; char* string; char buffer [256 + 1]; 10 12 struct sockaddr_in servAddr; I/ Check and set program arguments if (argc != 3) 13 14 15 16 printf ("Error: three arguments are needed!"); exit(1): servName=argv[1]; servPort = atoi (argv[2]); string = argv[3]; // Build server socket address memset (&servVAddr, 0, sizeof (servAddr)): servAddr.sin_family = AF_INET; inet_pton (AF_INET, servName, &servAddr.sin addr); servAddr.sin port = htons (servPort): // Create socket if ((s = socket (PF_INET, SOCK_DGRAM, 0) < 0); perror ("Error: Socket failed!"): exit (1); I/ Send echo string len = sendto (s, string, strlen (string), 0, (struct sockaddr)&servAddr, sizeof (servAddr)); I/ Receive echo string recvfrom (s, buffer, len, 0, NULL, NULL); // Print and verify echoed string 38 buffer [len] = "0'; printf ("Echo string received: "; fputs (buffer, stdout); I/ Close the socket 40 41 close (s);s 43 // Stop the program 44 exit (0): 45 J// End of echo client program
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 63% (11 reviews)
This is the general UDP client program in the C langu...View the full answer
Answered By
Jeff Omollo
As an educator I have had the opportunity to work with students of all ages and backgrounds. Throughout my career, I have developed a teaching style that encourages student engagement and promotes active learning. My education and tutoring skills has enabled me to empower students to become lifelong learners.
5.00+
5+ Reviews
49+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
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 Table 25.1 Echo server program using...
-
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...
-
Which of the following is indeterminate at x = 1? x + 1 x-1' 2-1 x + 2 x - 1 x+3-2' x + 1 x+3-2
-
Shareholders' equity on the balance sheet is divided into major components. Identify and explain what each component represents.
-
Aretta J. Parkinson owned a two-hundred-acre farm in a State that requires written authority for an agent to sell land. Prior to her death on December 23, Parkinson deeded a one-eighth undivided...
-
Selected accounts of Albright Consulting, Inc., a financial services business, have the following balances at January 31,2010, the end of its first year of operations. During the year, Lilly...
-
Product S is normally sold for $13 per unit. A special price of $9 is offered for the export market. The variable production cost is $7 per unit. An additional export tariff of 30% of revenue must be...
-
How's Business uses a standard costing system.Management budgets for 200 units to be produced per period.Fixed factory overhead at this level is $15,000.The standard costs per unit are as follows:...
-
1. Pick a futures that you are interested in. ie, a commodity (iron, barley, etc), financial futures (index), etc. 2. State the market your research is based on ie, ASX, CBOE, etc. 3. Put in a price...
-
In Figure 25.12 in the text, how is the socket created for data transfer at the server site? Figure 25.12 Figure 25.12 Socket data structure Length Family Port number IP address Family Type Protocol...
-
Explain which entity provides service and which one receives service in the client-server paradigm.
-
Discount Parking, near an airport, incurred the following costs to acquire land, make land improvements, and construct and furnish a small building: Discount Parking depreciates land improvements...
-
Binding energy is 2.00 eV and incoming photon energy is 3.1 eV. What is the electron's kinetic energy in joules. Electron mass is 9.109 x 10-28 g h= 6.626 x 10-34 Js Converting eV to Joules (J) 1 eV...
-
A 2 8 kg child rides a merry go round, 3 . 3 m from the center. the merry go round makes one complete revolution every 7 seconds. how large is the net force on the child?
-
1. Given that water has a specific heat capacity of 1.00 cal/g/C, how much heat does it take to raise the temperature of 50.0 g of water from 19.0C to 27.5C? 2. Given that water has a specific heat...
-
The ____ of clay masonry units depends on the clays used, burning temperature, and the method of controlling it during the burn. a. texture b. heat transmission c. color d. fire resistance
-
You are dragging a 50 kg crate up your driveway which is inclined at an angle of 8 above the horizontal. You pull with a 230 N that is parallel to the driveway. The coefficient of kinetic friction...
-
How can the Internet be used as a platform to implement distributed multilayer applications? Which Internet and Web protocols are used, and how are they used?
-
The MIT Sloan School of Management is one of the leading business schools in the U.S. The following table contains the tuition data for the masters program in the Sloan School of Management. a. Use...
-
What is polyglot persistence, and why is it considered a new approach?
-
What are the key assumptions made by the Hadoop Distributed File System approach?
-
What is the difference between a name node and a data node in HDFS?
-
At the end of the current year, Accounts Receivable has a balance of $880,000, Allowance for Doubtful Accounts has a credit balance of $8,000, and sales for the year total $3,960,000. Bad debt...
-
On January 1 of this year, Ikuta Company issued a bond with a face value of $120,000 and a coupon rate of 5 percent. The bond matures in 3 years and pays interest every December 31. When the bond was...
-
Discuss the impact of enzyme engineering and directed evolution in the development of enzymes with enhanced or novel catalytic activities for industrial or pharmaceutical applications .
Study smarter with the SolutionInn App