subject

For this lab, you are going to alter those send/receive loops in both vcsend and vcrec to instead use select() to determine whether to call send() or recv(). In the setup for select(), tell it to monitor both stdin and the data socket for read activities.
You will call send() when there is read activity on standard in, which indicates the user has typed something on the keyboard. If the user has typed just a period (.) on a line by itself that indicates that the user wishes to close the connection so you would close instead of calling send().

You will call recv() when there is read activity on the data socket. If recv() is successful (returns greater than 0), print the data to the screen. Otherwise (returns 0 or negative number), handle as the original vcrec. c handled those return values of recv().

Be sure to prompt the user for input in each iteration of the select() loop. The prompt can be any text you choose, but be sure to indicate that the user types '.' on a line by itself to close the connection.

Test your code by running vcrec in one terminal and then running vcsend in a second terminal. You must have two terminals running since both programs will be watching stdin. Have vcsend connect to vcrec's port. You should be able to type in either program whenever you want and have the data display via stdout on the other program. Both programs should terminate when you type '.' on a single line in either program.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 03:00
Jason, samantha, ravi, sheila, and ankit are preparing for an upcoming marathon. each day of the week, they run a certain number of miles and write them into a notebook. at the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. write a program to them analyze their data. your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results. (you may assume that the input data is stored in a file and each line of data is in the following form: runnername milesday1 milesday2 milesday3 milesday4 milesday5 milesday6 milesday7.)
Answers: 3
question
Computers and Technology, 23.06.2019 05:00
Acompany is inviting design for its new corporate logo from its users. this is an example of ? a. crowdfunding b. crowdvoting c. crowdsourced design d. crowdtracking
Answers: 3
question
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
You know the right answer?
For this lab, you are going to alter those send/receive loops in both vcsend and vcrec to instead us...
Questions
question
Mathematics, 11.07.2021 02:40
question
Mathematics, 11.07.2021 02:40
question
Physics, 11.07.2021 02:40
question
Mathematics, 11.07.2021 02:40
Questions on the website: 13722362