TCP Socket Programming (PC to PC) Create a Server side socket programming. The server side will...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
TCP Socket Programming (PC to PC) Create a Server side socket programming. The server side will send out a message every second. Setup server socket with a port number. Assume the port number is 8081.+ Create a message for sending out the client. You will need to use: BufferedWriter. OutputStreamWriter. s.getOutputStream(+ The mapping should be like the following: new BufferedWriter(new OutputStreamWriter(s.getOutputStream()))+ Input the message by writing it into the buffer-writer. The code will look like the following: <Your_attribute_name> write(<Your message>);< Use the "flush" method to push the data out from the buffer. <Your attribute name> flush();< But if the data is not enough to perform a push effect, the newLine() method to give a break point on the buffer. The looping can be done by using thread and a loop. Set the thread to sleep for every 1000 millisecond by using the "sleep" method. The client side is similar like server side; it only omits the ServerSocket. The IP is referring to Server side and port number is referring to the opened port that server side turned on. Create a message for receiveddata from server. You will need to use: BufferedReader. InputStreamReader. s.getInputStream(+ The mapping should be like the following:+ new BufferedReader (new InputStreamReader(s. getinputStream()))+ In order to read the message, you will need to use the "readLine" method.+ <Your attribute_name>.readLine();< Please always check if the received data is NULL or not. If the data is not NULL, print out a line of words of that message. There is also a looping feature and a thread in the client side. In order to lower the amount of client process, set the thread to sleep for every 1000 millisecond by using the "sleep" method. P P + TCP Socket Programming (PC to PC) Create a Server side socket programming. The server side will send out a message every second. Setup server socket with a port number. Assume the port number is 8081.+ Create a message for sending out the client. You will need to use: BufferedWriter. OutputStreamWriter. s.getOutputStream(+ The mapping should be like the following: new BufferedWriter(new OutputStreamWriter(s.getOutputStream()))+ Input the message by writing it into the buffer-writer. The code will look like the following: <Your_attribute_name> write(<Your message>);< Use the "flush" method to push the data out from the buffer. <Your attribute name> flush();< But if the data is not enough to perform a push effect, the newLine() method to give a break point on the buffer. The looping can be done by using thread and a loop. Set the thread to sleep for every 1000 millisecond by using the "sleep" method. The client side is similar like server side; it only omits the ServerSocket. The IP is referring to Server side and port number is referring to the opened port that server side turned on. Create a message for receiveddata from server. You will need to use: BufferedReader. InputStreamReader. s.getInputStream(+ The mapping should be like the following:+ new BufferedReader (new InputStreamReader(s. getinputStream()))+ In order to read the message, you will need to use the "readLine" method.+ <Your attribute_name>.readLine();< Please always check if the received data is NULL or not. If the data is not NULL, print out a line of words of that message. There is also a looping feature and a thread in the client side. In order to lower the amount of client process, set the thread to sleep for every 1000 millisecond by using the "sleep" method. P P +
Expert Answer:
Answer rating: 100% (QA)
Heres a Java code example for the serverside socket programming import javaio import javanet public ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Craps is a dice game in which two fair dice are cast. If the roller shoots a 7 or 11 on the rst roll, he or she wins. If the roller shoots a 2, 3, or 12 on the rst roll, he or she loses. (a) Compute...
-
How many revolutions per minute would a 25-mdiameter Ferris wheel need to make for the passengers to feel "weightless" at the topmost point?
-
A car salesperson has six automobiles on the car lot. Roll a die, using the numbers 1 through 6 to represent each car. If only one car can be sold on each day, how long will it take him to sell all...
-
Identify the most appropriate approach and then design. Provide a rationale as to why this approach and design would be most appropriate. Develop a hypothetical research scenario that would...
-
Prepare Financial Statements. The Childrens Counseling Center was incorporated as a not-for-profit voluntary health and welfare organization 10 years ago. Its adjusted trial balance as of June 30,...
-
A swimmer wants to cross a river, from point A to point B, as shown in the figure. The distance di (from A to C) is 200 m, the distance d (from C to B) is 150 m, and the speed vr of the current in...
-
After a series of large project disasters, what country is requiring people to complete a new academic program in project management before leading a large government project? a. Australia b. U.K. c....
-
When a large Omaha Department store moved to a new location, Linda Butler was hired as the new shoe department manager. Harold Knox, who retired, had been the manager at the old location. Lindas...
-
When the teacher gave an exercise after the lesson, the teacher found that students were not able recall what was explained. Explain, using any forgetting theory why this could have happened. Also...
-
rewrite longer In January 2023, Apple announced that in 2024, it will bring back manufacturing in-house. Several factors may influence Apple's decision to insource certain operations or functions....
-
The Daytona 500 features 40 race cars. Of the 40, 19 cars crashed. This is a 0.475 probability that a car will crash in the race. This is an example of what probability?
-
determine the future value of a present value of $37,500 at 2% annual interest compounded monthly for 17 years, and determine the amount of interest earned. The future value is and the interest...
-
A bond with a face value of 22,000 and a 5.55.5% interest rate (compounded semiannually) will mature in 20 years years. What is a fair price to pay for the bond today?
-
Imagine that you are Magna's new corporate controller and answer the following: 1. Describe Magna's strategy in terms of how it competes for customers. 2. Based on Magna's strategy and the data...
-
If M = 7, s = 2, and X = 9.5, what is z?
-
Harold Conners (Social Security number 785-23-9873) lives at 13234 DeMilo Drive, Houston, TX 77052, and is self-employed for 2012. He estimates his required annual estimated tax payment for 2012 to...
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
Sally hires a maid to work in her home for $250 per month. The maid is 25 years old and not related to Sally. During 2012, the maid worked 10 months for Sally. a. What is the amount of Social...
-
Bonnie and Clyde have a partnership to run their human resource management services firm. Account balances related to their equity for the year ended 30 June 2020 are as follows. Profit of $124 000...
-
Lewis Edwards decides to branch out on his own and set up his own private practice as an accountant. Events occurring in March 2019 are as follows. Ignore GST. Required (a) After analyzing the events...
-
On 1 March 2017, James Taylor decided to open Taylors Tailormade that makes suits, trousers and jackets, and repairs and alters clothes. He contributed for this purpose sewing equipment $46 000 and a...
Study smarter with the SolutionInn App