Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming a) Consider the Server side code written in class (use Port 7777 instead of Port 90 since Port 90 is restricted). Save this

Java programming

image text in transcribed

a) Consider the Server side code written in class (use Port 7777 instead of Port 90 since Port 90 is restricted). Save this code under "server" class. import java.net.*; import java.io.*; import java.util.*; public class server {public static void main (String args[]){try {ServerSocket s = new ServerSocket(7777); Socket ss = accept(); DataInputStream dis = new DataInputStream(ss.getInputStream()); DataOutput Stream dout = new DataOutputStream(ss.getoutputStream()); String sclient = dis.readUTF(); dout.writeUTF("I got your message");}catch (Exception e) {System.out.printIn("Error: " + e);}}} b) Based on your Assignment #14, write the client side code to connect to the server side. The client code sends a message (e.g. "Hello Server") to the server, and waits to receive a response from the server. It then prints the response (message) sent by the server. Note that the hostname of the server side is "localhost" (or IP Address of 127.0.0.1). Save the client side code under "client" class. c) On the terminal run the two compiled programs (server and client as follows): $javac server.java//to compile server java program $javac client.java//to compile client.java program $java server &//to run server program in the "background" java client//to run client program in the foreground which will interact//with already running server program in the

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions