Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TCP Socket Programming (PC to PC) Create a Server side socket programming. The server side will send out a message every second. Setup server


 image text in transcribed

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: write( ); < Use the "flush" method to push the data out from the buffer. 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.+ .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 +

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a Java code example for the serverside socket programming import javaio import javanet public ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

Students also viewed these Programming questions